[Feature]: configure whitespace error highlighting
evanrichter opened this issue · comments
Description
git diff
on the terminal highlights incorrect whitespace in the terminal. Example:
But in gex (tested with 0.5.0 using nix run nixpkgs#gex
), this whitespace error isn't shown:
Additional Information
The git diff flag to use is --ws-error-highlight
, and I think an appropriate value would be new
.
wait, should this actually be a bug report?
It seems like running the git command doesn't read my user level git config either, for some reason, even when I set diff.wsErrorHighlight = new
It seems like running the git command doesn't read my user level git config either, for some reason, even when I set diff.wsErrorHighlight = new
My guess is git doesn't render the highlighting because it doesn't detect a TTY due to the pipe... I suspect this can be fixed super easily by just passing --color
flag, but I wonder if there's a more general way to make the subprocess think it's talking to TTY
Thanks for opening this issue! I will look into it
Edit: when you referred to "running the git command" I interpreted this as using the : button to execute the command, but it just occurred to me that you might be referring to the underlying git diff
that gex executes during a status refresh.
For the latter it is a reasonable solution to try just passing --color
, but this won't be completely trivial as currently all the highlighting is done by gex after already being stripped from git's output (because of no-TTY), so this fix will require getting rid of that logic which sounds like a good thing but there are some potential problems
- If git doesn't reset its colouring for each line then this will cause problems when scrolling is considered, as the ANSI sequences to set the colours may be outside of the printed window
- In future I plan to possibly move all of the painting logic to the
render
module, because
a) it makes more sense there and
b) this will make it a lot easier and cleaner to resolve #37
c) almost definitely will make painting simpler for #21
when you referred to "running the git command" ...
ah, sorry, I was just talking about the main gex output. I noticed the way the diff is generated (here, for unstaged commits) is like:
Line 450 in f71214d
so my comment was about running git like this seems to ignore the config I explicitly set. The TTY detection theory makes sense
Released in 0.6 🎉