comparison 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
comparison
equal deleted inserted replaced
31889:56fd2c6e8425 31890:2d96d7f9da7e
1693 #endif 1693 #endif
1694 vim_free(globaldir); 1694 vim_free(globaldir);
1695 globaldir = aco->globaldir; 1695 globaldir = aco->globaldir;
1696 1696
1697 // the buffer contents may have changed 1697 // the buffer contents may have changed
1698 VIsual_active = aco->save_VIsual_active;
1698 check_cursor(); 1699 check_cursor();
1699 if (curwin->w_topline > curbuf->b_ml.ml_line_count) 1700 if (curwin->w_topline > curbuf->b_ml.ml_line_count)
1700 { 1701 {
1701 curwin->w_topline = curbuf->b_ml.ml_line_count; 1702 curwin->w_topline = curbuf->b_ml.ml_line_count;
1702 #ifdef FEAT_DIFF 1703 #ifdef FEAT_DIFF
1739 } 1740 }
1740 1741
1741 curwin = save_curwin; 1742 curwin = save_curwin;
1742 curbuf = curwin->w_buffer; 1743 curbuf = curwin->w_buffer;
1743 prevwin = win_find_by_id(aco->save_prevwin_id); 1744 prevwin = win_find_by_id(aco->save_prevwin_id);
1745
1744 // In case the autocommand moves the cursor to a position that 1746 // In case the autocommand moves the cursor to a position that
1745 // does not exist in curbuf. 1747 // does not exist in curbuf.
1748 VIsual_active = aco->save_VIsual_active;
1746 check_cursor(); 1749 check_cursor();
1747 } 1750 }
1748 } 1751 }
1749 1752
1753 VIsual_active = aco->save_VIsual_active;
1750 check_cursor(); // just in case lines got deleted 1754 check_cursor(); // just in case lines got deleted
1751 VIsual_active = aco->save_VIsual_active;
1752 if (VIsual_active) 1755 if (VIsual_active)
1753 check_pos(curbuf, &VIsual); 1756 check_pos(curbuf, &VIsual);
1754 } 1757 }
1755 1758
1756 static int autocmd_nested = FALSE; 1759 static int autocmd_nested = FALSE;