vim-patch:9.0.1277: cursor may move with autocmd in Visual mode (#22116)

Problem:    Cursor may move with autocmd in Visual mode.
Solution:   Restore "VIsual_active" before calling check_cursor().
            (closes vim/vim#11939)

49f0524fb5
This commit is contained in:
zeertzjq
2023-02-04 19:35:31 +08:00
committed by GitHub
parent 964ae205a5
commit 90333b24c3
2 changed files with 14 additions and 2 deletions

View File

@@ -1535,6 +1535,7 @@ win_found:
globaldir = aco->globaldir;
// the buffer contents may have changed
VIsual_active = aco->save_VIsual_active;
check_cursor();
if (curwin->w_topline > curbuf->b_ml.ml_line_count) {
curwin->w_topline = curbuf->b_ml.ml_line_count;
@@ -1563,14 +1564,16 @@ win_found:
curwin = save_curwin;
curbuf = curwin->w_buffer;
prevwin = win_find_by_handle(aco->save_prevwin_handle);
// In case the autocommand moves the cursor to a position that does not
// exist in curbuf
VIsual_active = aco->save_VIsual_active;
check_cursor();
}
}
check_cursor(); // just in case lines got deleted
VIsual_active = aco->save_VIsual_active;
check_cursor(); // just in case lines got deleted
if (VIsual_active) {
check_pos(curbuf, &VIsual);
}