]> granicus.if.org Git - vim/commitdiff
patch 8.1.2363: ml_get error when accessing Visual area in 'statusline' v8.1.2363
authorBram Moolenaar <Bram@vim.org>
Sat, 30 Nov 2019 14:05:22 +0000 (15:05 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 30 Nov 2019 14:05:22 +0000 (15:05 +0100)
Problem:    ml_get error when accessing Visual area in 'statusline'.
Solution:   Disable Visual mode when using another window. (closes #5278)

src/buffer.c
src/testdir/test_statusline.vim
src/version.c

index cba84c629acd2538b51811aa517a40c6a15fa846..3b50c8937942ecb97b702e3afd53e75146711fc2 100644 (file)
@@ -3979,6 +3979,7 @@ build_stl_str_hl(
 #ifdef FEAT_EVAL
     win_T      *save_curwin;
     buf_T      *save_curbuf;
+    int                save_VIsual_active;
 #endif
     int                empty_line;
     colnr_T    virtcol;
@@ -4368,13 +4369,18 @@ build_stl_str_hl(
 
            save_curbuf = curbuf;
            save_curwin = curwin;
+           save_VIsual_active = VIsual_active;
            curwin = wp;
            curbuf = wp->w_buffer;
+           // Visual mode is only valid in the current window.
+           if (curwin != save_curwin)
+               VIsual_active = FALSE;
 
            str = eval_to_string_safe(p, &t, use_sandbox);
 
            curwin = save_curwin;
            curbuf = save_curbuf;
+           VIsual_active = save_VIsual_active;
            do_unlet((char_u *)"g:actual_curbuf", TRUE);
            do_unlet((char_u *)"g:actual_curwin", TRUE);
 
index e1830d08baf60125dd9a386a980389f01f8db566..af05be58e13907683d55ea4121a1e0d7ae096499 100644 (file)
@@ -368,3 +368,25 @@ func Test_statusline()
   set laststatus&
   set splitbelow&
 endfunc
+
+func Test_statusline_visual()
+  func CallWordcount()
+    call wordcount()
+  endfunc
+  new x1
+  setl statusline=count=%{CallWordcount()}
+  " buffer must not be empty
+  call setline(1, 'hello')
+
+  " window with more lines than x1
+  new x2
+  call setline(1, range(10))
+  $
+  " Visual mode in line below liast line in x1 should not give ml_get error
+  call feedkeys("\<C-V>", "xt")
+  redraw
+
+  delfunc CallWordcount
+  bwipe! x1
+  bwipe! x2
+endfunc
index 5833f382475be9cbb2c8c5a332cec3a4d0b09867..1bb77a1b1d5b602cef8ce82c9aab9de6c3584a43 100644 (file)
@@ -737,6 +737,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2363,
 /**/
     2362,
 /**/