]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1759: Visual highlight not working with cursor at end of screen line v9.0.1759
authorzeertzjq <zeertzjq@outlook.com>
Sun, 20 Aug 2023 16:12:54 +0000 (18:12 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 20 Aug 2023 16:12:54 +0000 (18:12 +0200)
Problem:  Visual highlight not working with cursor at end of screen line
          and 'showbreak'.
Solution: Only update "vcol_prev" when drawing buffer text.

closes: #12865

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
src/drawline.c
src/testdir/dumps/Test_visual_hl_with_showbreak.dump [new file with mode: 0644]
src/testdir/test_visual.vim
src/version.c

index 0be071876f0c9a011bee653d6f47413e2280d7ee..88d72cedd59687917540d576223255f4c5192100 100644 (file)
@@ -3792,9 +3792,11 @@ win_line(
        }
 #endif
 
+       if (wlv.draw_state == WL_LINE)
+           vcol_prev = wlv.vcol;
+
        // Store character to be displayed.
        // Skip characters that are left of the screen for 'nowrap'.
-       vcol_prev = wlv.vcol;
        if (wlv.draw_state < WL_LINE || n_skip <= 0)
        {
            // Store the character.
diff --git a/src/testdir/dumps/Test_visual_hl_with_showbreak.dump b/src/testdir/dumps/Test_visual_hl_with_showbreak.dump
new file mode 100644 (file)
index 0000000..fa0b2dc
--- /dev/null
@@ -0,0 +1,6 @@
+|a+0&#ffffff0@48>a
+|++0#4040ff13&|a+0#0000000#e0e0e08@3|a+0&#ffffff0@5| @38
+|~+0#4040ff13&| @48
+|~| @48
+|~| @48
+|-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@9|5| @8|1|,|5|0| @9|A|l@1| 
index f152e7b79ba805653954031538185b2824857882..58b73929479a45d2756a37b152c731ed5968b6a1 100644 (file)
@@ -1554,5 +1554,23 @@ func Test_heap_buffer_overflow()
   set updatecount&
 endfunc
 
+" Test Visual highlight with cursor at end of screen line and 'showbreak'
+func Test_visual_hl_with_showbreak()
+  CheckScreendump
+
+  let lines =<< trim END
+    setlocal showbreak=+
+    call setline(1, repeat('a', &columns + 10))
+    normal g$v4lo
+  END
+  call writefile(lines, 'XTest_visual_sbr', 'D')
+
+  let buf = RunVimInTerminal('-S XTest_visual_sbr', {'rows': 6, 'cols': 50})
+  call VerifyScreenDump(buf, 'Test_visual_hl_with_showbreak', {})
+
+  " clean up
+  call term_sendkeys(buf, "\<Esc>")
+  call StopVimInTerminal(buf)
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index b858a1015d447dde1256d803b3019b5d51f7d4be..2da6a2074e8a765c7943ba6d99ef94014f186db1 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1759,
 /**/
     1758,
 /**/