jesseduffield / lazygit

simple terminal UI for git commands
MIT License
53.05k stars 1.85k forks source link

Misrendered highlighting with diff-so-fancy #2176

Closed fredcallaway closed 2 years ago

fredcallaway commented 2 years ago

When using diff-so-fancy as the pager, lazygit incorrectly renders the highlighted change in a line. Specifically, it highlights everything after the change in a line instead of just the section that was changed. See comparison of lg and diff-so-fancy below:

image

My best guess is that the end-highlight marker is getting ignored.

Originally posted by @fredcallaway in https://github.com/jesseduffield/lazygit/issues/190#issuecomment-1245779998

jesseduffield commented 2 years ago

Looks like we have an ANSI escape code that we're not properly honouring in vendor/github.com/jesseduffield/gocui/escape.go

fredcallaway commented 2 years ago

I unfortunately don't have the go chops to make a pull request myself. But I can tell you that the relevant escape code is 27, which means "not reverse". For example, here is the output of git diff | diff-so-fancy | less (after switching back to "second" back to "first".

ESC[1;31mthis is the ESC[7msecondESC[27m thing hereESC[0m
ESC[1;32mthis is the ESC[7mfirstESC[27m thing hereESC[0m
scottchiefbaker commented 7 months ago

diff-so-fancy maintainer here... Happy to see it being used in the wild.