Problem: When text with 'leadmultispace' (or other listchars whitespace
characters) is visually selected, the listchar characters do not
render with their designated highlight group (Whitespace/NonText).
They inherit the syntax color of surrounding text instead.
Solution: In win_line(), when attr_pri is set (Visual selection active),
combine extra_attr with char_attr using hl_combine_attr() instead
of skipping the assignment entirely.
fixes: #19872
pwd
/Users/dipayandutta/Developer/vim-official
cat /tmp/repro.vim
─────┬────────────────────────────────────────────────────────────────────────────────────
│ File: /tmp/repro.vim
─────┼────────────────────────────────────────────────────────────────────────────────────
1 │ set nocompatible
2 │ set list
3 │ set listchars=leadmultispace:|\ \ \ <----------
4 │ set expandtab tabstop=4 shiftwidth=4
5 │ highlight Whitespace ctermfg=1
6 │ highlight Visual ctermbg=4
─────┴────────────────────────────────────────────────────────────────────────────────────
cat /tmp/testfile.py
─────┬────────────────────────────────────────────────────────────────────────────────────
│ File: /tmp/testfile.py
─────┼────────────────────────────────────────────────────────────────────────────────────
1 │ def foo():
2 │ if True:
3 │ pass
─────┴───────────────────
src/vim -u /tmp/repro.vim /tmp/testfile.py
image.png (view on web)
https://github.com/vim/vim/pull/19877
(1 file)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
@zeertzjq commented on this pull request.
In src/drawline.c:
> + if (wlv.line_attr) + wlv.char_attr = hl_combine_attr(wlv.line_attr, + hl_combine_attr(wlv.extra_attr, wlv.char_attr)); + else #endif - wlv.char_attr = wlv.extra_attr; + wlv.char_attr = hl_combine_attr(wlv.extra_attr, wlv.char_attr);
This gives char_attr higher priority than extra_attr, but previously only extra_attr is used. I wonder if it's better to give extra_attr higher priority instead:
- if (wlv.line_attr) - wlv.char_attr = hl_combine_attr(wlv.line_attr, - hl_combine_attr(wlv.extra_attr, wlv.char_attr)); - else -#endif - wlv.char_attr = wlv.extra_attr; - wlv.char_attr = hl_combine_attr(wlv.extra_attr, wlv.char_attr); + if (wlv.line_attr) + wlv.char_attr = hl_combine_attr(wlv.line_attr, + hl_combine_attr(wlv.char_attr, wlv.extra_attr)); + else +#endif + wlv.char_attr = hl_combine_attr(wlv.char_attr, wlv.extra_attr);
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
thanks. I fixed your message formatting. I assume this was done using AI?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Hi @chrisbra I tried by myself. But in hurry did not check the precedence .
Thanks for the message.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
No worries. Can you please include a test case? Check the Test_listchars_foldcolumn() test inside testdir/test_listchars.vim which uses a screen dump test to verify the highlighting.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I cannot see what is wrong with the current version. Can you give a reproducible example and what it should look like?
I tried to make a test of your repro, but it does not fail before/after your patch:
func Test_listchars_multispace_visual() CheckScreendump let lines =<< trim END set list set listchars=leadmultispace:\|\ \ \ ,eol:$ set expandtab tabstop=4 shiftwidth=4 highlight NonText ctermfg=1 highlight Visual ctermbg=4 END let py =<< trim END def foo(): if True: pass END call writefile(lines, 'XTest_multispace', 'D') call writefile(py, 'Xfoobar.py', 'D') let buf = RunVimInTerminal('-S XTest_multispace Xfoobar.py', {'rows': 10, 'cols': 20}) call term_sendkeys(buf, "gg0") call VerifyScreenDump(buf, 'Test_leadmultispace_01', {}) call term_sendkeys(buf, "VG$") call VerifyScreenDump(buf, 'Test_leadmultispace_02', {}) " clean up call StopVimInTerminal(buf) endfunc
So how to see the difference?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
So how to see the difference?
I believe Visual should set ctermfg to NONE to make it work.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
this has stalled, so closing
—
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.![]()