aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-26 23:53:55 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-26 23:56:21 +0800
commite0d6703a6a37592780c0d6c02ea8802fc531cf62 (patch)
treeb9f8c624e08708fd6c745029deeedc05dfc1dc85
parent9f0762f1fec2aa23df592dda70124e3cbdb703b7 (diff)
downloadrneovim-e0d6703a6a37592780c0d6c02ea8802fc531cf62.tar.gz
rneovim-e0d6703a6a37592780c0d6c02ea8802fc531cf62.tar.bz2
rneovim-e0d6703a6a37592780c0d6c02ea8802fc531cf62.zip
vim-patch:9.0.1490: the ModeChanged event may be triggered too often
Problem: The ModeChanged event may be triggered too often. Solution: Only trigger ModeChanged when no operator is pending. (closes vim/vim#12298) https://github.com/vim/vim/commit/73916bac5ac2a054a0c71adfe8d742691cdfd95c
-rw-r--r--src/nvim/normal.c14
-rw-r--r--test/old/testdir/test_autocmd.vim4
2 files changed, 10 insertions, 8 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 2bafeccba4..635d177ecc 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -956,10 +956,12 @@ normal_end:
set_reg_var(get_default_register_name());
}
- // Reset finish_op, in case it was set
s->c = finish_op;
- finish_op = false;
- may_trigger_modechanged();
+ if (s->oa.op_type == OP_NOP) {
+ // Reset finish_op, in case it was set
+ finish_op = false;
+ may_trigger_modechanged();
+ }
// Redraw the cursor with another shape, if we were in Operator-pending
// mode or did a replace command.
if (s->c || s->ca.cmdchar == 'r'
@@ -1729,9 +1731,9 @@ void prep_redo_num2(int regname, long num1, int cmd1, int cmd2, long num2, int c
}
}
-/// check for operator active and clear it
+/// Check for operator active and clear it.
///
-/// @return true if operator was active
+/// Beep and return true if an operator was active.
static bool checkclearop(oparg_T *oap)
{
if (oap->op_type == OP_NOP) {
@@ -1743,7 +1745,7 @@ static bool checkclearop(oparg_T *oap)
/// Check for operator or Visual active. Clear active operator.
///
-/// @return true if operator or Visual was active.
+/// Beep and return true if an operator or Visual was active.
static bool checkclearopq(oparg_T *oap)
{
if (oap->op_type == OP_NOP && !VIsual_active) {
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index decfec4763..c44988321f 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -3453,7 +3453,7 @@ endfunc
" Test for ModeChanged pattern
func Test_mode_changes()
let g:index = 0
- let g:mode_seq = ['n', 'i', 'n', 'v', 'V', 'i', 'ix', 'i', 'ic', 'i', 'n', 'no', 'n', 'V', 'v', 's', 'n']
+ let g:mode_seq = ['n', 'i', 'n', 'v', 'V', 'i', 'ix', 'i', 'ic', 'i', 'n', 'no', 'noV', 'n', 'V', 'v', 's', 'n']
func! TestMode()
call assert_equal(g:mode_seq[g:index], get(v:event, "old_mode"))
call assert_equal(g:mode_seq[g:index + 1], get(v:event, "new_mode"))
@@ -3464,7 +3464,7 @@ func Test_mode_changes()
au ModeChanged * :call TestMode()
let g:n_to_any = 0
au ModeChanged n:* let g:n_to_any += 1
- call feedkeys("i\<esc>vVca\<CR>\<C-X>\<C-L>\<esc>ggdG", 'tnix')
+ call feedkeys("i\<esc>vVca\<CR>\<C-X>\<C-L>\<esc>ggdV\<MouseMove>G", 'tnix')
let g:V_to_v = 0
au ModeChanged V:v let g:V_to_v += 1