changeset 15991:f362d695bcf9 v8.1.1001

patch 8.1.1001: Visual area not correct when using 'cursorline' commit https://github.com/vim/vim/commit/8156ed37558231a8167a1a61a147713d84c9af59 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 9 11:46:15 2019 +0100 patch 8.1.1001: Visual area not correct when using 'cursorline' Problem: Visual area not correct when using 'cursorline'. Solution: Update w_last_cursorline also in Visual mode. (Hirohito Higashi, closes #4086)
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 Mar 2019 12:00:05 +0100
parents 5c53c3aced6a
children 6a0f44d8d497
files src/screen.c src/testdir/dumps/Test_cursorline_with_visualmode_01.dump src/testdir/test_highlight.vim src/version.c
diffstat 4 files changed, 44 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/screen.c
+++ b/src/screen.c
@@ -3704,14 +3704,16 @@ win_line(
 #endif
 
 #ifdef FEAT_SYN_HL
-    /* Cursor line highlighting for 'cursorline' in the current window.  Not
-     * when Visual mode is active, because it's not clear what is selected
-     * then. */
-    if (wp->w_p_cul && lnum == wp->w_cursor.lnum
-					 && !(wp == curwin && VIsual_active))
-    {
-	line_attr = HL_ATTR(HLF_CUL);
-	area_highlighting = TRUE;
+    // Cursor line highlighting for 'cursorline' in the current window.
+    if (wp->w_p_cul && lnum == wp->w_cursor.lnum)
+    {
+	// Do not show the cursor line when Visual mode is active, because it's
+	// not clear what is selected then.  Do update w_last_cursorline.
+	if (!(wp == curwin && VIsual_active))
+	{
+	    line_attr = HL_ATTR(HLF_CUL);
+	    area_highlighting = TRUE;
+	}
 	wp->w_last_cursorline = wp->w_cursor.lnum;
     }
 #endif
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_cursorline_with_visualmode_01.dump
@@ -0,0 +1,12 @@
+|a+0&#e0e0e08|b|c| | +0&#ffffff0@70
+|a+0&#e0e0e08|b|c| | +0&#ffffff0@70
+|a+0&#e0e0e08|b|c| | +0&#ffffff0@70
+|a+0&#e0e0e08|b|c| | +0&#ffffff0@70
+|a+0&#e0e0e08|b|c| | +0&#ffffff0@70
+>a|b+0&#e0e0e08|c| | +0&#ffffff0@70
+|a|b|c| @71
+|a|b|c| @71
+|a|b|c| @71
+|a|b|c| @71
+|a|b|c| @71
+|-+2&&@1| |V|I|S|U|A|L| |L|I|N|E| |-@1| +0&&@29|1|2| @7|1|2|,|1| @9|1|5|%| 
--- a/src/testdir/test_highlight.vim
+++ b/src/testdir/test_highlight.vim
@@ -552,3 +552,23 @@ func Test_cursorline_after_yank()
   call StopVimInTerminal(buf)
   call delete('Xtest_cursorline_yank')
 endfunc
+
+func Test_cursorline_with_visualmode()
+  if !CanRunVimInTerminal()
+    return
+  endif
+
+  call writefile([
+	\ 'set cul',
+	\ 'call setline(1, repeat(["abc"], 50))',
+	\ ], 'Xtest_cursorline_with_visualmode')
+  let buf = RunVimInTerminal('-S Xtest_cursorline_with_visualmode', {'rows': 12})
+  call term_wait(buf)
+  call term_sendkeys(buf, "V\<C-f>kkkjk")
+
+  call VerifyScreenDump(buf, 'Test_cursorline_with_visualmode_01', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('Xtest_cursorline_with_visualmode')
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -780,6 +780,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1001,
+/**/
     1000,
 /**/
     999,