From: Hirohito Higashi Date: Sun, 21 Jun 2026 14:09:31 +0000 (+0000) Subject: patch 9.2.0688: Terminal-Normal mode does not show the Visual selection on a colored... X-Git-Tag: v9.2.0688^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65228691d9d9008fd637fbf50cad68e63554e5fb;p=thirdparty%2Fvim.git patch 9.2.0688: Terminal-Normal mode does not show the Visual selection on a colored empty line Problem: In Terminal-Normal mode the Visual selection is not visible on the first cell of an empty line that was erased with a background color (CSI K after e.g. CSI 100m); a plain empty line shows it but a colored one does not. Solution: Combine the Visual or search highlight onto the first cell on top of the explicitly set background color, the same way it shows with the default background. closes: #20580 Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- diff --git a/src/drawline.c b/src/drawline.c index 1747f67f45..86911cefc2 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -3696,6 +3696,17 @@ win_line( else if (wlv.line_attr) wlv.char_attr = hl_combine_attr( wlv.char_attr, wlv.line_attr); + // Show a Visual or search highlight on the first cell + // of an empty line, on top of the background color. + if (wlv.vcol == 0) + { + if (area_attr != 0) + wlv.char_attr = hl_combine_attr( + wlv.char_attr, area_attr); + else if (search_attr != 0) + wlv.char_attr = hl_combine_attr( + wlv.char_attr, search_attr); + } } # endif } diff --git a/src/testdir/dumps/Test_terminal_visual_colored_empty.dump b/src/testdir/dumps/Test_terminal_visual_colored_empty.dump new file mode 100644 index 0000000000..c44f068302 --- /dev/null +++ b/src/testdir/dumps/Test_terminal_visual_colored_empty.dump @@ -0,0 +1,10 @@ +| +0#0000001#a8a8a8255| +0#0000000#8080809@73 +|o+0#0000001#a8a8a8255|l|d| +0#0000000#8080809@71 +| +0#0000001#a8a8a8255| +0#0000000#8080809@73 +> +0&#ffffff0@74 +|!+2#ffffff16#00e0003|s|h| |.|/|X|t|e|r|m|_|c|o|l|o|r|e|d|.|s|h| |[|f|i|n|i|s|h|e|d|]| @23|4|,|0|-|1| @9|A|l@1 +| +0#0000000#ffffff0@74 +|~+0#4040ff13&| @73 +|~| @73 +|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1 +|-+2&&@1| |V|I|S|U|A|L| |L|I|N|E| |-@1| +0&&@46|4| @9 diff --git a/src/testdir/test_terminal3.vim b/src/testdir/test_terminal3.vim index 8bbef4fd69..22d19909a5 100644 --- a/src/testdir/test_terminal3.vim +++ b/src/testdir/test_terminal3.vim @@ -1062,6 +1062,28 @@ func Test_terminal_normal_mode_colored_empty_line() call StopVimInTerminal(buf) endfunc +func Test_terminal_visual_colored_empty_line() + CheckScreendump + CheckRunVimInTerminal + CheckUnix + + " Empty lines erased with a gray background (CSI 100m, CSI K). When such a + " line is selected in Terminal-Normal mode the Visual highlight must show on + " its first cell, while the rest of the line keeps the background color. + call writefile(["printf '\\033[100m\\033[K\\nold\\033[K\\n\\033[K\\033[0m\\n'"], + \ 'Xterm_colored.sh', 'D') + call writefile([':set listchars=', ':term sh ./Xterm_colored.sh'], + \ 'XtermColored', 'D') + let buf = RunVimInTerminal('-S XtermColored', #{rows: 10}) + call term_wait(buf) + + call term_sendkeys(buf, "\NggVG") + call term_wait(buf) + call VerifyScreenDump(buf, 'Test_terminal_visual_colored_empty', {}) + + call StopVimInTerminal(buf) +endfunc + func Test_terminal_ansi_color_windows_cui() if !has('win32') || has('gui_running') throw 'Skipped: only for the Windows CUI' diff --git a/src/version.c b/src/version.c index 75976074d8..917e637732 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 688, /**/ 687, /**/