[vim/vim] update diff colors for environments with <=256 colors (PR #20711)

24 views
Skip to first unread message

Maxim Kim

unread,
Jul 5, 2026, 2:56:10 AMJul 5
to vim/vim, Subscribed

It is hard to read "transparent" diff colors in environments where number of colors are limited.
Make sure foreground color is set, so that diff colors are not clashing with syntax colors.

Closes #4071


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20711

Commit Summary

  • d03d1af update diff colors for environments with <=256 colors

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711@github.com>

Maxim Kim

unread,
Jul 5, 2026, 3:06:57 AMJul 5
to vim/vim, Subscribed
habamax left a comment (vim/vim#20711)

@chrisbra this would be a slightly breaking change for people relying on the current Diff* groups not setting foreground color. Same way it was with Visual back when you did a similar change.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c4885185047@github.com>

Maxim Kim

unread,
Jul 5, 2026, 3:10:07 AMJul 5
to vim/vim, Subscribed
habamax left a comment (vim/vim#20711)

Additionally, I am not sure what foreground color would be better to set black or white.
It might be better to set black for &background == "light" and white for &background == "dark".


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c4885193071@github.com>

Maxim Kim

unread,
Jul 5, 2026, 4:08:16 AMJul 5
to vim/vim, Subscribed
habamax left a comment (vim/vim#20711)

I am not sure how to fix this test:

Failures: 
	From test_highlight.vim:
	Found errors in Test_highlight_eol_on_diff():
	command line..script /home/runner/work/vim/vim/src/testdir/runtest.vim[636]..function RunTheTest[63]..Test_highlight_eol_on_diff line 18: Expected 2093 but got 2143
func Test_highlight_eol_on_diff()
  call setline(1, ['abcd', ''])
  call matchadd('Search', '\n')
  let attrs0 = ScreenAttrs(1, 10)[0]

  diffthis
  botright new
  diffthis

  " expected:
  " '  abcd    '
  "  ^^           sign
  "    ^^^^ ^^^   'DiffAdd' highlight
  "        ^      'Search' highlight
  let attrs = ScreenAttrs(1, 10)[0]
  call assert_equal(repeat([attrs[0]], 2), attrs[0:1])
  call assert_equal(repeat([attrs[2]], 4), attrs[2:5])
  call assert_equal(repeat([attrs[2]], 3), attrs[7:9])
  call assert_equal(attrs0[4], attrs[6])
  call assert_notequal(attrs[0], attrs[2])
  call assert_notequal(attrs[0], attrs[6])
  call assert_notequal(attrs[2], attrs[6])
  call Check_lcs_eol_attrs(attrs, 1, 10)

  bwipe!
  diffoff
endfunc


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c4885335246@github.com>

Maxim Kim

unread,
Jul 5, 2026, 8:20:02 AMJul 5
to vim/vim, Subscribed
habamax left a comment (vim/vim#20711)

Omg, so many screendumps, my eyes are bleeding.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c4886008685@github.com>

Maxim Kim

unread,
Jul 5, 2026, 8:50:55 AMJul 5
to vim/vim, Subscribed
habamax left a comment (vim/vim#20711)

I am not sure how to fix this test:

Failures: 
	From test_highlight.vim:
	Found errors in Test_highlight_eol_on_diff():
	command line..script /home/runner/work/vim/vim/src/testdir/runtest.vim[636]..function RunTheTest[63]..Test_highlight_eol_on_diff line 18: Expected 2093 but got 2143

So it was about using Search highlight group which only sets ctermbg but not ctermfg. Using ErrorMsg instead, fixes the test.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c4886097211@github.com>

Christian Brabandt

unread,
Jul 22, 2026, 1:21:48 PMJul 22
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20711)

Thanks. I merge it, but I am expecting some complaints, so I may roll-back if there is too much backlash.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c5049257905@github.com>

Maxim Kim

unread,
Jul 22, 2026, 8:26:30 PMJul 22
to vim/vim, Subscribed
habamax left a comment (vim/vim#20711)

Thx, there might be complaints in the future, once it hits distros, however this PR is to workout existing complaint about unreadable diff colors.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c5052992841@github.com>

Maxim Kim

unread,
Aug 12, 2026, 12:08:01 PM (4 days ago) Aug 12
to vim/vim, Subscribed
habamax left a comment (vim/vim#20711)

Doesn't it mean we lose syntax highlighting in diff mode?

Yes, for default colorscheme in non gui mode.

I wonder what percentage of default colorscheme users benefit the change and the opposite.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c5265311440@github.com>

lantw44

unread,
Aug 12, 2026, 12:18:53 PM (4 days ago) Aug 12
to vim/vim, Subscribed
lantw44 left a comment (vim/vim#20711)

Doesn't it mean we lose syntax highlighting in diff mode?

Image: 圖片 (view on web)
It becomes much harder to read for large changes, which can happen when reviewing a large commit.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c5264899792@github.com>

lantw44

unread,
Aug 14, 2026, 2:39:28 AM (2 days ago) Aug 14
to vim/vim, Subscribed
lantw44 left a comment (vim/vim#20711)

I found that I can bring back syntax highlighting with set termguicolors.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20711/c5290313114@github.com>

Reply all
Reply to author
Forward
0 new messages