To: vim_dev@googlegroups.com Subject: Patch 9.0.1490 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1490 Problem: The ModeChanged event may be triggered too often. Solution: Only trigger ModeChanged when no operator is pending. (closes #12298) Files: src/normal.c, src/testdir/test_autocmd.vim *** ../vim-9.0.1489/src/normal.c 2023-04-13 21:47:33.361227019 +0100 --- src/normal.c 2023-04-26 16:47:45.566049337 +0100 *************** *** 975,986 **** reset_reg_var(); #endif - // Reset finish_op, in case it was set #ifdef CURSOR_SHAPE int prev_finish_op = finish_op; #endif ! finish_op = FALSE; ! may_trigger_modechanged(); #ifdef CURSOR_SHAPE // Redraw the cursor with another shape, if we were in Operator-pending // mode or did a replace command. --- 975,989 ---- reset_reg_var(); #endif #ifdef CURSOR_SHAPE int prev_finish_op = finish_op; #endif ! if (oap->op_type == OP_NOP) ! { ! // Reset finish_op, in case it was set ! finish_op = FALSE; ! may_trigger_modechanged(); ! } #ifdef CURSOR_SHAPE // Redraw the cursor with another shape, if we were in Operator-pending // mode or did a replace command. *************** *** 995,1001 **** #endif if (oap->op_type == OP_NOP && oap->regname == 0 ! && ca.cmdchar != K_CURSORHOLD) clear_showcmd(); checkpcmark(); // check if we moved since setting pcmark --- 998,1004 ---- #endif if (oap->op_type == OP_NOP && oap->regname == 0 ! && ca.cmdchar != K_CURSORHOLD) clear_showcmd(); checkpcmark(); // check if we moved since setting pcmark *************** *** 1496,1504 **** } /* ! * check for operator active and clear it * ! * return TRUE if operator was active */ static int checkclearop(oparg_T *oap) --- 1499,1507 ---- } /* ! * Check for operator active and clear it. * ! * Beep and return TRUE if an operator was active. */ static int checkclearop(oparg_T *oap) *************** *** 1512,1518 **** /* * Check for operator or Visual active. Clear active operator. * ! * Return TRUE if operator or Visual was active. */ static int checkclearopq(oparg_T *oap) --- 1515,1521 ---- /* * Check for operator or Visual active. Clear active operator. * ! * Beep and return TRUE if an operator or Visual was active. */ static int checkclearopq(oparg_T *oap) *** ../vim-9.0.1489/src/testdir/test_autocmd.vim 2023-04-15 21:27:55.550844924 +0100 --- src/testdir/test_autocmd.vim 2023-04-26 16:47:45.570049335 +0100 *************** *** 3672,3678 **** " 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'] 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")) --- 3672,3678 ---- " 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', '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")) *************** *** 3683,3689 **** au ModeChanged * :call TestMode() let g:n_to_any = 0 au ModeChanged n:* let g:n_to_any += 1 ! call feedkeys("i\vVca\\\\ggdG", 'tnix') let g:V_to_v = 0 au ModeChanged V:v let g:V_to_v += 1 --- 3683,3689 ---- au ModeChanged * :call TestMode() let g:n_to_any = 0 au ModeChanged n:* let g:n_to_any += 1 ! call feedkeys("i\vVca\\\\ggdV\G", 'tnix') let g:V_to_v = 0 au ModeChanged V:v let g:V_to_v += 1 *** ../vim-9.0.1489/src/version.c 2023-04-26 15:43:36.606094298 +0100 --- src/version.c 2023-04-26 16:49:13.070005569 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1490, /**/ -- LARGE MAN: Who's that then? CART DRIVER: (Grudgingly) I dunno, Must be a king. LARGE MAN: Why? CART DRIVER: He hasn't got shit all over him. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///