From 3f419d84fbb918836fd90f2e09eace7ce3266f6b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 10 Feb 2024 06:53:26 +0800 Subject: 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 https://github.com/vim/vim/commit/c9e79e52845d51f48f5ea3753a62ab3fe0e40184 Cherry-pick test_autocmd.vim change from patch 8.2.4149. Co-authored-by: Christian Brabandt --- src/nvim/edit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 41df039b85..b7b32883c2 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -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) -- cgit