]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4028: ml_get error with :doautoall and Visual area v8.2.4028
authorBram Moolenaar <Bram@vim.org>
Fri, 7 Jan 2022 15:45:18 +0000 (15:45 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 7 Jan 2022 15:45:18 +0000 (15:45 +0000)
Problem:    ml_get error with :doautoall and Visual area. (Sean Dewar)
Solution:   Disable Visual mode while executing autocommands.

src/autocmd.c
src/structs.h
src/testdir/test_autocmd.vim
src/version.c

index 862370fc6ed05b83814d60a9453138876ad0fa8f..37f2480a88972922ef2c72dcb56e3ae87c7ef08a 100644 (file)
@@ -1424,8 +1424,6 @@ ex_doautoall(exarg_T *eap)
        if (call_do_modelines && did_aucmd)
            do_modelines(0);
     }
-
-    check_cursor();        // just in case lines got deleted
 }
 
 /*
@@ -1532,6 +1530,10 @@ aucmd_prepbuf(
     curbuf = buf;
     aco->new_curwin_id = curwin->w_id;
     set_bufref(&aco->new_curbuf, curbuf);
+
+    // disable the Visual area, the position may be invalid in another buffer
+    aco->save_VIsual_active = VIsual_active;
+    VIsual_active = FALSE;
 }
 
 /*
@@ -1656,6 +1658,11 @@ win_found:
            check_cursor();
        }
     }
+
+    check_cursor();        // just in case lines got deleted
+    VIsual_active = aco->save_VIsual_active;
+    if (VIsual_active)
+       check_pos(curbuf, &VIsual);
 }
 
 static int     autocmd_nested = FALSE;
index 197df720c53fa9c82405df5c342e6b8f171521ca..9d5768175fb2e2dfc07e5852df7c9e5f886659b5 100644 (file)
@@ -4031,6 +4031,7 @@ typedef struct
     int                save_prevwin_id;    // ID of saved prevwin
     bufref_T   new_curbuf;         // new curbuf
     char_u     *globaldir;         // saved value of globaldir
+    int                save_VIsual_active; // saved VIsual_active
 } aco_save_T;
 
 /*
index b6f621dbff12ba215658cb75edf06031e7877e7b..1fc960f537d63aa9554e2671e8c305e2cd90c22d 100644 (file)
@@ -2812,6 +2812,16 @@ func Test_close_autocmd_tab()
   %bwipe!
 endfunc
 
+func Test_Visual_doautoall_redraw()
+  call setline(1, ['a', 'b'])
+  new 
+  wincmd p
+  call feedkeys("G\<C-V>", 'txn')
+  autocmd User Explode ++once redraw
+  doautoall User Explode
+  %bwipe!
+endfunc
+
 " This was using freed memory.
 func Test_BufNew_arglocal()
   arglocal
index 731f8cef1de62f27758e4bd117ac81f2ce10c444..53202e515959c77f5a7deda36b480c4d0c501557 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4028,
 /**/
     4027,
 /**/