]> granicus.if.org Git - vim/commitdiff
patch 8.1.1001: Visual area not correct when using 'cursorline' v8.1.1001
authorBram Moolenaar <Bram@vim.org>
Sat, 9 Mar 2019 10:46:15 +0000 (11:46 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 9 Mar 2019 10:46:15 +0000 (11:46 +0100)
Problem:    Visual area not correct when using 'cursorline'.
Solution:   Update w_last_cursorline also in Visual mode. (Hirohito Higashi,
            closes #4086)

src/screen.c
src/testdir/dumps/Test_cursorline_with_visualmode_01.dump [new file with mode: 0644]
src/testdir/test_highlight.vim
src/version.c

index eabf7c18680db5bbfd5e1db60d8bac8f4f971cb7..111c77d8a0c740ce861fd7670969beb5c9a107f7 100644 (file)
@@ -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))
+    // Cursor line highlighting for 'cursorline' in the current window.
+    if (wp->w_p_cul && lnum == wp->w_cursor.lnum)
     {
-       line_attr = HL_ATTR(HLF_CUL);
-       area_highlighting = TRUE;
+       // 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
diff --git a/src/testdir/dumps/Test_cursorline_with_visualmode_01.dump b/src/testdir/dumps/Test_cursorline_with_visualmode_01.dump
new file mode 100644 (file)
index 0000000..b6e20b7
--- /dev/null
@@ -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|%| 
index b37684c6f5a7caa1de8386222081456d68f8d064..e16abf18372844080e9f78b350b4f6bfe8c57812 100644 (file)
@@ -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
index e4e6b3ce8f5b153f159ce09a4f154566f23aeb45..248b8414b71233682c80c45f12f64a26212ee910 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1001,
 /**/
     1000,
 /**/