The standard pager for git will highlight additions of lines whose only content are spaces or tabs in red. The same for any trailing whitespace. Is it possible to have similar behavior in delta?
Thanks in advance.
Hi @herbygillot, this is a good call, thanks!
Notes to help implementing a fix / unit tests for this:
Here's an example
diff --git a/z.js b/z.js
index cf70fdb..c528683 100644
--- a/z.js
+++ b/z.js
@@ -3,5 +3,6 @@ function test() {
}
+
test();
console.log("this isn't in the hunk!")
which git --no-pager diff displays as
![]() |
but with delta this is
![]() |
By reading the documentation, I was expecting that forcing something like --whitespace-error-style 'red reverse' would give me that behaviour.
--whitespace-error-style
Style for whitespace errors. Defaults to color.diff.whitespace if that is set in git config, or else
'magenta reverse' [default: auto auto]
Unfortunately, it also does not work.
Hi @aureliojargas, let me give a quick response where I may be missing something:
I actually thought that this was fixed and that I'd forgotten to close the issue. Which delta version are you using? With 0.3.0 this is what I get using the diff pasted above. Is this what you want the output to be?
![]() |
Hi @dandavison, thanks for the super quick answer!
From what I can tell, it seems it is working correctly for lines containing only whitespace (as in your test), but not for lines with content and trailing whitespace. I'm using delta 0.3.0 in macOS 10.13.6.
Considering a text file foo that has a single x line, I've added two spaces after the x and a new line with another two spaces.
echo x > foo
git add foo
echo -e "x \n " > foo
git diff foo > foo.diff
Note that the plain git diff marks both cases as red, while delta does it only in the empty line:

Please tell me if you need additional tests or information from my side, I'm glad to help.
Thanks @aureliojargas that鈥檚 very helpful. I should be able to get a fix in shortly.
Most helpful comment
Thanks @aureliojargas that鈥檚 very helpful. I should be able to get a fix in shortly.