aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2022-01-07 17:33:01 +0000
committerSean Dewar <seandewar@users.noreply.github.com>2022-02-03 15:03:08 +0000
commit6820420d3e7c153868e21d917596b3d1a19fa937 (patch)
tree3617a7baf1806b25fdeaf69c2dc66f3f3dcd69ac /src
parentd984a8d130c2063dcd33ae52f98c22fe3567cd18 (diff)
downloadrneovim-6820420d3e7c153868e21d917596b3d1a19fa937.tar.gz
rneovim-6820420d3e7c153868e21d917596b3d1a19fa937.tar.bz2
rneovim-6820420d3e7c153868e21d917596b3d1a19fa937.zip
vim-patch:8.2.4028: ml_get error with :doautoall and Visual area
Problem: ml_get error with :doautoall and Visual area. (Sean Dewar) Solution: Disable Visual mode while executing autocommands. https://github.com/vim/vim/commit/cb1956d6f2aece8ad93e19e5d4c7e0b5e405f056 This should also fix #16937 for nvim_buf_call, so test for it.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/autocmd.c12
-rw-r--r--src/nvim/autocmd.h1
-rw-r--r--src/nvim/testdir/test_autocmd.vim10
3 files changed, 21 insertions, 2 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 94ac389139..2e7f9c5136 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -1069,8 +1069,6 @@ void ex_doautoall(exarg_T *eap)
do_modelines(0);
}
}
-
- check_cursor(); // just in case lines got deleted
}
/// Check *argp for <nomodeline>. When it is present return false, otherwise
@@ -1171,6 +1169,10 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf)
curbuf = buf;
aco->new_curwin_handle = curwin->handle;
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;
}
/// Cleanup after executing autocommands for a (hidden) buffer.
@@ -1267,6 +1269,12 @@ 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);
+ }
}
/// Execute autocommands for "event" and file name "fname".
diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h
index ac12e2acf3..63c5abd4f8 100644
--- a/src/nvim/autocmd.h
+++ b/src/nvim/autocmd.h
@@ -14,6 +14,7 @@ typedef struct {
handle_T save_prevwin_handle; ///< ID of saved prevwin
bufref_T new_curbuf; ///< new curbuf
char_u *globaldir; ///< saved value of globaldir
+ bool save_VIsual_active; ///< saved VIsual_active
} aco_save_T;
typedef struct AutoCmd {
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index 231ab2acf1..433410248b 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -2543,6 +2543,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
+
func Test_autocmd_closes_window()
au BufNew,BufWinLeave * e %e
file yyy