aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-02 10:56:40 +0800
committerGitHub <noreply@github.com>2023-12-02 10:56:40 +0800
commitc45d1e32a92f5027fe12038b856509efe5c158fb (patch)
tree492b01ed1fed314cf279bb84857db1527be91d19 /src/nvim/window.c
parent387c5ba3de356ea5c5f6fe71465440abd8563d8e (diff)
parent9d7544ac4cd553c9b7c8b41926b7292c5ee85943 (diff)
downloadrneovim-c45d1e32a92f5027fe12038b856509efe5c158fb.tar.gz
rneovim-c45d1e32a92f5027fe12038b856509efe5c158fb.tar.bz2
rneovim-c45d1e32a92f5027fe12038b856509efe5c158fb.zip
Merge pull request #26358 from zeertzjq/vim-9.0.2140
vim-patch:9.0.{2140,2141,2142,2143}
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 7728efde33..ef1ef89d95 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4470,11 +4470,12 @@ void tabpage_move(int nr)
redraw_tabline = true;
}
-// Go to another window.
-// When jumping to another buffer, stop Visual mode. Do this before
-// changing windows so we can yank the selection into the '*' register.
-// When jumping to another window on the same buffer, adjust its cursor
-// position to keep the same Visual area.
+/// Go to another window.
+/// When jumping to another buffer, stop Visual mode. Do this before
+/// changing windows so we can yank the selection into the '*' register.
+/// (note: this may trigger ModeChanged autocommand!)
+/// When jumping to another window on the same buffer, adjust its cursor
+/// position to keep the same Visual area.
void win_goto(win_T *wp)
{
win_T *owp = curwin;
@@ -4485,11 +4486,17 @@ void win_goto(win_T *wp)
}
if (wp->w_buffer != curbuf) {
+ // careful: triggers ModeChanged autocommand
reset_VIsual_and_resel();
} else if (VIsual_active) {
wp->w_cursor = curwin->w_cursor;
}
+ // autocommand may have made wp invalid
+ if (!win_valid(wp)) {
+ return;
+ }
+
win_enter(wp, true);
// Conceal cursor line in previous window, unconceal in current window.