delta icon indicating copy to clipboard operation
delta copied to clipboard

πŸ› side-by-side does not apply zero-styles for empty lines

Open elbaro opened this issue 3 years ago β€’ 6 comments

[delta]
  features = side-by-side line-numbers decorations
  zero-style = syntax "#EEEEEE"

When using side-by-side with a terminal background color overriding, the color does not apply to empty lines.

image

elbaro avatar Mar 24 '21 08:03 elbaro

Hi @elbaro, thanks for this and sorry I didn't respond at the time you opened it. It's an interesting point -- I think the issue, at least in part, is that delta has so far been designed for the background colors to be used for emphasis. But it is not doing well, as you say, if you try to use delta to supply the default background color everywhere (I had imagined that users would use their terminal emulator to set the default background color).

dandavison avatar Dec 06 '21 04:12 dandavison

Delta emphasizes the whole line 87 in the screenshot instead of only the text part "assert window_size > 0". Doesn't that mean we should color the whole line 88 because the line is emphasized?

One problem relying on terminal background is remote machines. When delta is installed on the remote server, I sometimes ssh to it via dark terminal and sometimes light terminal.

elbaro avatar Dec 12 '21 11:12 elbaro

Hi @elbaro, can you post

  1. An example diff that demonstrates the problem
  2. The command line you are using and the output of delta --show-config
  3. Your delta version?

I tried to reproduce it with this diff:

diff --git a/src/cli.rs b/src/cli.rs
index e047889..6794917 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -320,7 +320,7 @@ pub struct Opt {
     pub color_only: bool,
 
     pub features: String,

But that seems to work correctly:

delta --no-gitconfig --side-by-side --zero-style='black white' < the_diff.diff
image

dandavison avatar Dec 12 '21 14:12 dandavison

Please make sure you're using the latest version of delta -- the implementation of side-by-side was rewritten this year, and I think that this bug may have been fixed already.

dandavison avatar Dec 12 '21 14:12 dandavison

@dandavison @elbaro Hi. I am having the same problem with the latest version.

❯ delta --version
delta 0.13.0

This occurs under the following conditions:

  • use side-by-side
  • line-numbers-zero-style via features

for example:

[delta]
	side-by-side = true
	features = line-numbers-style

[delta "line-numbers-style"]
	line-numbers = true
	line-numbers-zero-style = "#ffffff"  # doesn't work
γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2022-08-11 20 21 24

but this is works:

[delta]
	side-by-side = true
	line-numbers = true
	line-numbers-zero-style = "#ffffff"  # ok
γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2022-08-11 20 21 46

ornew avatar Aug 11 '22 11:08 ornew

I found that works when side-by-side and zero-style placed in the same feature.

[delta]
	features = line-numbers-style

[delta "line-numbers-style"]
	side-by-side = true
	line-numbers = true
	line-numbers-zero-style = "#ffffff"
γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2022-08-11 20 39 43

ornew avatar Aug 11 '22 11:08 ornew