From ac353e87aecf02315d82a3ad22725d2bc8140f0c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 28 Oct 2023 10:42:18 +0800 Subject: vim-patch:9.0.2075: TextChangedI may not always trigger (#25808) Problem: TextChangedI may not always trigger Solution: trigger it in more cases: for insert/ append/change operations, and when opening a new line, fixes: vim/vim#13367 closes: vim/vim#13375 https://github.com/vim/vim/commit/4bca4897a12dfb91b3b27e3083fd5f370bd857d1 Co-authored-by: Christian Brabandt --- test/old/testdir/test_autocmd.vim | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'test/old') diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index 447a716331..a2b46daff3 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -2476,28 +2476,27 @@ func Test_ChangedP() call cursor(3, 1) let g:autocmd = '' call feedkeys("o\", 'tnix') - " `TextChangedI` triggers only if text is actually changed in Insert mode - call assert_equal('', g:autocmd) + call assert_equal('I', g:autocmd) let g:autocmd = '' call feedkeys("Sf", 'tnix') - call assert_equal('I', g:autocmd) + call assert_equal('II', g:autocmd) let g:autocmd = '' call feedkeys("Sf\", 'tnix') - call assert_equal('IP', g:autocmd) + call assert_equal('IIP', g:autocmd) let g:autocmd = '' call feedkeys("Sf\\", 'tnix') - call assert_equal('IPP', g:autocmd) + call assert_equal('IIPP', g:autocmd) let g:autocmd = '' call feedkeys("Sf\\\", 'tnix') - call assert_equal('IPPP', g:autocmd) + call assert_equal('IIPPP', g:autocmd) let g:autocmd = '' call feedkeys("Sf\\\\", 'tnix') - call assert_equal('IPPPP', g:autocmd) + call assert_equal('IIPPPP', g:autocmd) call assert_equal(['foo', 'bar', 'foobar', 'foo'], getline(1, '$')) " TODO: how should it handle completeopt=noinsert,noselect? @@ -3489,6 +3488,25 @@ func Test_Changed_ChangedI() call feedkeys("ibar\", 'tnix') call assert_equal('', g:autocmd_n) + " If change is a mix of Normal and Insert modes, TextChangedI should trigger + func s:validate_mixed_textchangedi(keys) + call feedkeys("ifoo\", 'tnix') + let g:autocmd_i = '' + let g:autocmd_n = '' + call feedkeys(a:keys, 'tnix') + call assert_notequal('', g:autocmd_i) + call assert_equal('', g:autocmd_n) + endfunc + + call s:validate_mixed_textchangedi("o\") + call s:validate_mixed_textchangedi("O\") + call s:validate_mixed_textchangedi("ciw\") + call s:validate_mixed_textchangedi("cc\") + call s:validate_mixed_textchangedi("C\") + call s:validate_mixed_textchangedi("s\") + call s:validate_mixed_textchangedi("S\") + + " CleanUp call test_override("char_avail", 0) au! TextChanged -- cgit