summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_autocmd.vim
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2023-10-27 19:26:49 +0200
committerChristian Brabandt <cb@256bit.org>2023-10-27 19:26:49 +0200
commit4bca4897a12dfb91b3b27e3083fd5f370bd857d1 (patch)
treefb1e1775a2407a3865e97822f14a4996b4278294 /src/testdir/test_autocmd.vim
parentdaef8c74375141974d61b85199b383017644978c (diff)
patch 9.0.2075: TextChangedI may not always triggerv9.0.2075
Problem: TextChangedI may not always trigger Solution: trigger it in more cases: for insert/ append/change operations, and when opening a new line, fixes: #13367 closes: #13375 Signed-off-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Diffstat (limited to 'src/testdir/test_autocmd.vim')
-rw-r--r--src/testdir/test_autocmd.vim32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 1e1bb4540a..0652a6fb67 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -2566,28 +2566,27 @@ func Test_ChangedP()
call cursor(3, 1)
let g:autocmd = ''
call feedkeys("o\<esc>", '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\<C-N>", 'tnix')
- call assert_equal('IP', g:autocmd)
+ call assert_equal('IIP', g:autocmd)
let g:autocmd = ''
call feedkeys("Sf\<C-N>\<C-N>", 'tnix')
- call assert_equal('IPP', g:autocmd)
+ call assert_equal('IIPP', g:autocmd)
let g:autocmd = ''
call feedkeys("Sf\<C-N>\<C-N>\<C-N>", 'tnix')
- call assert_equal('IPPP', g:autocmd)
+ call assert_equal('IIPPP', g:autocmd)
let g:autocmd = ''
call feedkeys("Sf\<C-N>\<C-N>\<C-N>\<C-N>", '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?
@@ -3621,6 +3620,25 @@ func Test_Changed_ChangedI()
call feedkeys("ibar\<esc>", '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\<esc>", '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\<esc>")
+ call s:validate_mixed_textchangedi("O\<esc>")
+ call s:validate_mixed_textchangedi("ciw\<esc>")
+ call s:validate_mixed_textchangedi("cc\<esc>")
+ call s:validate_mixed_textchangedi("C\<esc>")
+ call s:validate_mixed_textchangedi("s\<esc>")
+ call s:validate_mixed_textchangedi("S\<esc>")
+
+
" CleanUp
call test_override("char_avail", 0)
au! TextChanged <buffer>