vim-patch:9.0.2031: TextChangedI may be triggered by non-insert mode change (#25656)

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: vim/vim#13265
closes: vim/vim#13338

d7ae263af8

Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
This commit is contained in:
zeertzjq
2023-10-15 17:14:18 +08:00
committed by GitHub
parent e5a424d78e
commit a350fb2976
3 changed files with 45 additions and 19 deletions

View File

@@ -143,6 +143,9 @@ static void insert_enter(InsertState *s)
update_Insstart_orig = true;
ins_compl_clear(); // clear stuff for CTRL-X mode
// Reset Changedtick_i, so that TextChangedI will only be triggered for stuff
// from insert mode
curbuf->b_last_changedtick_i = buf_get_changedtick(curbuf);
// Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx".
if (s->cmdchar != 'r' && s->cmdchar != 'v') {
@@ -356,6 +359,7 @@ static void insert_enter(InsertState *s)
ins_apply_autocmds(EVENT_INSERTLEAVE);
}
did_cursorhold = false;
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
}
static int insert_check(VimState *state)