aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-10-15 17:14:18 +0800
committerGitHub <noreply@github.com>2023-10-15 17:14:18 +0800
commita350fb2976d9b1e8b5753f557645a905f6da0d74 (patch)
tree2805388d8426ae8514f14279a363b0d05936cc3a /test/functional
parente5a424d78ed72613dd5ccc161578f9f6f853a0e8 (diff)
downloadrneovim-a350fb2976d9b1e8b5753f557645a905f6da0d74.tar.gz
rneovim-a350fb2976d9b1e8b5753f557645a905f6da0d74.tar.bz2
rneovim-a350fb2976d9b1e8b5753f557645a905f6da0d74.zip
vim-patch:9.0.2031: TextChangedI may be triggered by non-insert mode change (#25656)
Problem: `TextChangedI` can trigger on entering Insert mode if there was previously a change not in Insert mode. Solution: Make it trigger only when text is actually changed in Insert mode. closes: vim/vim#13265 closes: vim/vim#13338 https://github.com/vim/vim/commit/d7ae263af8f6a2da55ce3702d18c53ab1418bca7 Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/autocmd/textchanged_spec.lua27
1 files changed, 19 insertions, 8 deletions
diff --git a/test/functional/autocmd/textchanged_spec.lua b/test/functional/autocmd/textchanged_spec.lua
index ffeb76835d..b90a0fd020 100644
--- a/test/functional/autocmd/textchanged_spec.lua
+++ b/test/functional/autocmd/textchanged_spec.lua
@@ -25,14 +25,15 @@ it('TextChangedI and TextChangedP autocommands', function()
feed('o')
poke_eventloop()
feed('<esc>')
- eq('I', eval('g:autocmd'))
+ -- TextChangedI triggers only if text is actually changed in Insert mode
+ eq('', eval('g:autocmd'))
command([[let g:autocmd = '']])
feed('S')
poke_eventloop()
feed('f')
poke_eventloop()
- eq('II', eval('g:autocmd'))
+ eq('I', eval('g:autocmd'))
feed('<esc>')
command([[let g:autocmd = '']])
@@ -42,7 +43,7 @@ it('TextChangedI and TextChangedP autocommands', function()
poke_eventloop()
feed('<C-N>')
poke_eventloop()
- eq('IIP', eval('g:autocmd'))
+ eq('IP', eval('g:autocmd'))
feed('<esc>')
command([[let g:autocmd = '']])
@@ -54,7 +55,7 @@ it('TextChangedI and TextChangedP autocommands', function()
poke_eventloop()
feed('<C-N>')
poke_eventloop()
- eq('IIPP', eval('g:autocmd'))
+ eq('IPP', eval('g:autocmd'))
feed('<esc>')
command([[let g:autocmd = '']])
@@ -68,7 +69,7 @@ it('TextChangedI and TextChangedP autocommands', function()
poke_eventloop()
feed('<C-N>')
poke_eventloop()
- eq('IIPPP', eval('g:autocmd'))
+ eq('IPPP', eval('g:autocmd'))
feed('<esc>')
command([[let g:autocmd = '']])
@@ -83,7 +84,7 @@ it('TextChangedI and TextChangedP autocommands', function()
feed('<C-N>')
poke_eventloop()
feed('<C-N>')
- eq('IIPPPP', eval('g:autocmd'))
+ eq('IPPPP', eval('g:autocmd'))
feed('<esc>')
eq({'foo', 'bar', 'foobar', 'foo'}, eval('getline(1, "$")'))
@@ -117,7 +118,7 @@ it('TextChangedI with setline()', function()
end)
-- oldtest: Test_Changed_ChangedI()
-it('TextChanged is triggerd after TextChangedI', function()
+it('TextChangedI and TextChanged', function()
exec([[
let [g:autocmd_i, g:autocmd_n] = ['','']
@@ -141,10 +142,20 @@ it('TextChanged is triggerd after TextChangedI', function()
feed('o')
poke_eventloop()
feed('<esc>')
- eq('N5', eval('g:autocmd_n'))
+ eq('', eval('g:autocmd_n'))
eq('I5', eval('g:autocmd_i'))
command([[call feedkeys("yyp", 'tnix')]])
eq('N6', eval('g:autocmd_n'))
eq('I5', eval('g:autocmd_i'))
+
+ -- TextChangedI should only trigger if change was done in Insert mode
+ command([[let g:autocmd_i = '']])
+ command([[call feedkeys("yypi\<esc>", 'tnix')]])
+ eq('', eval('g:autocmd_i'))
+
+ -- TextChanged should only trigger if change was done in Normal mode
+ command([[let g:autocmd_n = '']])
+ command([[call feedkeys("ibar\<esc>", 'tnix')]])
+ eq('', eval('g:autocmd_n'))
end)