Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 odd color-words colouring #440

Closed
paulirish opened this issue Dec 8, 2020 · 4 comments · Fixed by #807
Closed

🐛 odd color-words colouring #440

paulirish opened this issue Dec 8, 2020 · 4 comments · Fixed by #807

Comments

@paulirish
Copy link

paulirish commented Dec 8, 2020

edit: I realized my original bug report on --word-diff is captured by the thread on #152

original report

I don't use word-diff very often, but it's occasionally useful. I noticed the color highlighting ain't great with delta. FWIW, this isn't high priority to me. :)

screenshots without and with delta:
image

(I've commented out all [color] and [delta] config for those)

In my case, using --max-line-distance with a few diff values didn't seem to change anything.

repro diff:

diff --git a/packs/joomla.js b/packs/joomla.js
index 2dd5c1c..4d29095 100644
--- a/packs/joomla.js
+++ b/packs/joomla.js
@@ -18 +18 @@ const UIStrings = {
  'offscreen-images': 'Install a [lazy-load Joomla plugin](https://extensions.joomla.org/instant-search/?jed_live%5Bquery%5D=lazy%20loading) that provides the ability to defer any offscreen images, or switch to a template that provides that functionality. Starting with Joomla 4.0, [-a dedicated lazy-loading plugin can be enabled by using-]{+all new images will [automatically](https://github.com/joomla/joomla-cms/pull/30748) get the `loading` attribute from+} the [-"Content - Lazy Loading Images" plugin. Also consider using [an AMP plugin](https://extensions.joomla.org/instant-search/?jed_live%5Bquery%5D=amp).',-]{+core.',+}

However, I'll change this bug report to be about --color-words.
It seems like delta handles some --color-words output well:

image

👍

but then other output gives it problems:

image

repro:

�[1mdiff --git a/packs/joomla.js b/packs/joomla.js�[m
�[1mindex 2dd5c1c..4d29095 100644�[m
�[1m--- a/packs/joomla.js�[m
�[1m+++ b/packs/joomla.js�[m
�[36m@@ -18 +18 @@�[m �[mconst UIStrings = {�[m
  'offscreen-images': 'Install a [lazy-load Joomla plugin](https://extensions.joomla.org/instant-search/?jed_live%5Bquery%5D=lazy%20loading) that provides the ability to defer any offscreen images, or switch to a template that provides that functionality. Starting with Joomla 4.0, �[31ma dedicated lazy-loading plugin can be enabled by using�[m�[32mall new images will [automatically](https://github.com/joomla/joomla-cms/pull/30748) get the `loading` attribute from�[m the �[31m"Content - Lazy Loading Images" plugin. Also consider using [an AMP plugin](https://extensions.joomla.org/instant-search/?jed_live%5Bquery%5D=amp).',�[m�[32mcore.',�[m

🤔

and here you asked if folks prefer delta's own highlighting...

Here's at least one case where delta's highlighting fails quite a bit (on --color-words output):

image

�[1mdiff --git a/packs/joomla.js b/packs/joomla.js�[m
�[1mindex 2dd5c1c..b18f833 100644�[m
�[1m--- a/packs/joomla.js�[m
�[1m+++ b/packs/joomla.js�[m
�[36m@@ -18 +18 @@�[m �[mconst UIStrings = {�[m
  'offscreen-images': �[31m'Install�[m�[32m'You can install�[m a [lazy-load Joomla plugin](https://extensions.joomla.org/instant-search/?jed_live%5Bquery%5D=lazy%20loading) that provides the ability to defer any offscreen images, or switch to a template that provides that functionality. Starting with Joomla 4.0, �[31ma dedicated lazy-loading plugin can be enabled by using�[m�[32mall new images will [automatically](https://github.com/joomla/joomla-cms/pull/30748) get the `loading` attribute from�[m the �[31m"Content - Lazy Loading Images" plugin. Also consider using [an AMP plugin](https://extensions.joomla.org/instant-search/?jed_live%5Bquery%5D=amp).',�[m�[32mcore.',�[m

i'm using 0.4.4.
cheers!

@paulirish paulirish changed the title 🐛 odd word-diff colouring 🐛 odd color-words colouring Dec 8, 2020
@dandavison
Copy link
Owner

Thanks @paulirish! I agree, both this and #152 would be good to fix soon.

@mrjoel
Copy link

mrjoel commented Feb 17, 2021

I just ran into this issue with --color-words myself, except in this case I'd argue that it's broken since all formatting distinction is lost. I use --color-words in many of my git alias configurations so am finding myself running into this a lot. I ran into this first with diffing my .gitconfig in reviewing incorporation of delta, with ini style files seemingly very prone to getting confused.

Simplified reproducing test cases I encountered are below. I do have the style zero-style = dim syntax including in my settings, and noted that the faulty example resulted in syntax highlighting being included, although I don't know if that's related or not.

Working Example

Original:

foo = bar

Change working copy to:

foo = baz

Running git diff --color-words | delta works as expected, highlighting "bar" and "baz" with respective minus and plus styles.

Faulty Example

Original (same as above but with a single leading space):

 foo = bar

Change working copy to:

 foo = baz

Running git diff --color-words | delta does not work as expected, instead it strips all color formatting and stacks the words next to each other, simply showing foo = barbaz, apparently in zero-style.

@dandavison
Copy link
Owner

The current release (0.10.3) refuses to handle --word-diff or --color-words at all, instead allowing the raw git output through. I think this is at least a step in the right direction since what delta was doing previously to that input was entirely invalid. I believe that fixes (in a sense at least) both issues reported here. #152 discusses the possibility of delta introducing its own handing of these inputs, or its own "squashed diff" format (i.e. additions and deletions highlighted in a single line). Thanks for the bug reports here!

@mrjoel
Copy link

mrjoel commented Dec 4, 2021

I just tested the new release and an initial testing am happy to confirm that the raw git formatting is preserved. That is indeed a marked improvement, thanks for taking this step!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants