diff options
author | Christian Brabandt <cb@256bit.org> | 2024-02-09 19:34:36 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-02-09 19:34:36 +0100 |
commit | c9e79e52845d51f48f5ea3753a62ab3fe0e40184 (patch) | |
tree | 35fe3e9e359b9ca62a31f6048d4e35b4a1e76858 /src | |
parent | 2975a54f285e5b4bf026c1dc706b5d90777d64e7 (diff) |
patch 9.1.0088: TextChanged not triggered for :norm! commandsv9.1.0088
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: #13967
closes: #13984
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/edit.c | 7 | ||||
-rw-r--r-- | src/testdir/test_autocmd.vim | 18 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/edit.c b/src/edit.c index e9a994f6b2..5760b06e86 100644 --- a/src/edit.c +++ b/src/edit.c @@ -843,7 +843,12 @@ doESCkey: if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C) ins_apply_autocmds(EVENT_INSERTLEAVE); did_cursorhold = FALSE; - curbuf->b_last_changedtick = 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 = CHANGEDTICK(curbuf); return (c == Ctrl_O); } continue; diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index be73c18197..6e1223275f 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -2706,6 +2706,24 @@ func Test_TextChangedI_with_setline() bwipe! endfunc +func Test_TextChanged_with_norm() + " For unknown reason this fails on MS-Windows + CheckNotMSWindows + CheckFeature terminal + let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3}) + call assert_equal('running', term_getstatus(buf)) + call term_sendkeys(buf, ":let g:a=0\<cr>") + call term_wait(buf, 50) + call term_sendkeys(buf, ":au! TextChanged * :let g:a+=1\<cr>") + call term_wait(buf, 50) + call term_sendkeys(buf, ":norm! ia\<cr>") + call term_wait(buf, 50) + call term_sendkeys(buf, ":echo g:a\<cr>") + call term_wait(buf, 50) + call WaitForAssert({-> assert_match('^1.*$', term_getline(buf, 3))}) + bwipe! +endfunc + func Test_Changed_FirstTime() CheckFeature terminal CheckNotGui diff --git a/src/version.c b/src/version.c index 08a78b6001..1332f46baa 100644 --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 88, +/**/ 87, /**/ 86, |