vim-patch:9.1.0088: TextChanged not triggered for :norm! commands (#27405)

Problem:  TextChanged not triggered for :norm! commands
          (machakann, after v9.0.2031)
Solution: Only reset curbuf->b_last_changedtick if TextChangedI
          was triggered in insert mode (and not blocked)

Note: for unknown reasons, the test fails on Windows (but seems to work
fine when running interactively)

fixes: vim/vim#13967
closes: vim/vim#13984

c9e79e5284

Cherry-pick test_autocmd.vim change from patch 8.2.4149.

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-02-10 06:53:26 +08:00
committed by GitHub
parent 0d4d3e4325
commit 3f419d84fb
3 changed files with 37 additions and 2 deletions

View File

@@ -363,7 +363,13 @@ static void insert_enter(InsertState *s)
ins_apply_autocmds(EVENT_INSERTLEAVE);
}
did_cursorhold = false;
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
// ins_redraw() triggers TextChangedI only when no characters
// are in the typeahead buffer, so only reset curbuf->b_last_changedtick
// if the TextChangedI was not blocked by char_avail() (e.g. using :norm!)
if (!char_avail()) {
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
}
}
static int insert_check(VimState *state)