]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0688: Terminal-Normal mode does not show the Visual selection on a colored... v9.2.0688
authorHirohito Higashi <h.east.727@gmail.com>
Sun, 21 Jun 2026 14:09:31 +0000 (14:09 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 21 Jun 2026 14:09:31 +0000 (14:09 +0000)
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) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/drawline.c
src/testdir/dumps/Test_terminal_visual_colored_empty.dump [new file with mode: 0644]
src/testdir/test_terminal3.vim
src/version.c

index 1747f67f456f7dd79437d6f4a0e5a53a3e6d3583..86911cefc281c8394bc8896797958289ab7093f2 100644 (file)
@@ -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 (file)
index 0000000..c44f068
--- /dev/null
@@ -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
index 8bbef4fd69cb79580cf614d0529e9ce5cc4cd28d..22d19909a581aa59258f0094152a0f0b896bd55f 100644 (file)
@@ -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, "\<C-W>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'
index 75976074d8dcdca7c044c25e4650a0e0c47a5b42..917e6377323d2922e9890a80e7bd82d21a6ccca7 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    688,
 /**/
     687,
 /**/