Mercurial > vim
diff src/autocmd.c @ 31890:2d96d7f9da7e v9.0.1277
patch 9.0.1277: cursor may move with autocmd in Visual mode
Commit: https://github.com/vim/vim/commit/49f0524fb575bb1cf4881e472afab7d37c579440
Author: zeertzjq <zeertzjq@outlook.com>
Date: Sat Feb 4 10:58:34 2023 +0000
patch 9.0.1277: cursor may move with autocmd in Visual mode
Problem: Cursor may move with autocmd in Visual mode.
Solution: Restore "VIsual_active" before calling check_cursor().
(closes #11939)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 04 Feb 2023 12:00:05 +0100 |
parents | b89cfd86e18e |
children | f3987fde6dea |
line wrap: on
line diff
--- a/src/autocmd.c +++ b/src/autocmd.c @@ -1695,6 +1695,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) { @@ -1741,14 +1742,16 @@ win_found: curwin = save_curwin; curbuf = curwin->w_buffer; prevwin = win_find_by_id(aco->save_prevwin_id); + // In case the autocommand moves the cursor to a position that // does not exist in curbuf. + VIsual_active = aco->save_VIsual_active; check_cursor(); } } + VIsual_active = aco->save_VIsual_active; check_cursor(); // just in case lines got deleted - VIsual_active = aco->save_VIsual_active; if (VIsual_active) check_pos(curbuf, &VIsual); }