comparison src/edit.c @ 33572:830a5f8053cb v9.0.2031

patch 9.0.2031: TextChangedI may be triggered by non-insert mode change Commit: https://github.com/vim/vim/commit/d7ae263af8f6a2da55ce3702d18c53ab1418bca7 Author: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Date: Sun Oct 15 09:59:00 2023 +0200 patch 9.0.2031: TextChangedI may be triggered by non-insert mode change Problem: `TextChangedI` can trigger on entering Insert mode if there was previously a change not in Insert mode. Solution: Make it trigger only when text is actually changed in Insert mode. closes: #13265 closes: #13338 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 15 Oct 2023 10:15:03 +0200
parents 9c4ee9389bb4
children 46cd1fc257de
comparison
equal deleted inserted replaced
33571:93082dd250b6 33572:830a5f8053cb
172 { 172 {
173 emsg(_(e_not_allowed_to_change_text_or_change_window)); 173 emsg(_(e_not_allowed_to_change_text_or_change_window));
174 return FALSE; 174 return FALSE;
175 } 175 }
176 ins_compl_clear(); // clear stuff for CTRL-X mode 176 ins_compl_clear(); // clear stuff for CTRL-X mode
177 // Reset Changedtick_i, so that TextChangedI will only be triggered for stuff
178 // from insert mode
179 curbuf->b_last_changedtick_i = CHANGEDTICK(curbuf);
177 180
178 /* 181 /*
179 * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". 182 * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx".
180 */ 183 */
181 if (cmdchar != 'r' && cmdchar != 'v') 184 if (cmdchar != 'r' && cmdchar != 'v')
838 // that the autocommands won't be executed. When mapped got_int 841 // that the autocommands won't be executed. When mapped got_int
839 // is not set, but let's keep the behavior the same. 842 // is not set, but let's keep the behavior the same.
840 if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C) 843 if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C)
841 ins_apply_autocmds(EVENT_INSERTLEAVE); 844 ins_apply_autocmds(EVENT_INSERTLEAVE);
842 did_cursorhold = FALSE; 845 did_cursorhold = FALSE;
846 curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
843 return (c == Ctrl_O); 847 return (c == Ctrl_O);
844 } 848 }
845 continue; 849 continue;
846 850
847 case Ctrl_Z: // suspend when 'insertmode' set 851 case Ctrl_Z: // suspend when 'insertmode' set