Skip to content

🚀 Highlight merge diffs and conflict markers #189

@rygwdn

Description

@rygwdn

When showing a patch for a merge with --cc or -c, git will generate patch prefixes that are two characters instead of just one, (e.g. ++ or -). Delta will highlight any lines that have a leading + or - but will not highlight lines with a leading space. I believe Delta should be highlighting the lines the same way git does (e.g. by ignoring the leading space so a - line is red and a + line is green).

Sample input from git show --cc 27d2427484c6efe283671300b48b5aadc7549c8a in this repo:

commit 27d2427484c6efe283671300b48b5aadc7549c8a
Merge: 55703ed 268887c
Author: Dan Davison <[email protected]>
Date:   Thu Apr 16 12:11:21 2020 -0400

    Merge branch 'master' into width-calc-fix

diff --cc Cargo.lock
index 9bd779d,5be85a6..cee10bb
--- a/Cargo.lock
+++ b/Cargo.lock
@@@ -293,11 -358,15 +358,16 @@@ dependencies =
   "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
   "shell-words 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
   "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
-  "syntect 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+  "syntect 4.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
   "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  ]

+ [[package]]
+ name = "glob"
+ version = "0.3.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+
  [[package]]
  name = "heck"
  version = "0.3.1"
diff --cc Cargo.toml
index 914197f,cde6620..8e33592
--- a/Cargo.toml
+++ b/Cargo.toml
@@@ -27,9 -27,8 +27,9 @@@ lazy_static = "1.4
  regex = "1.2.1"
  shell-words = "0.1.0"
  structopt = "0.2.18"
- syntect = "3.2.0"
+ syntect = "4.1.0"
  unicode-segmentation = "1.3.0"
 +unicode-width = "0.1.6"

  [dependencies.error-chain]
  version = "0.12.1"

Git native highlighting:
image

Delta highlighting:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions