comparison src/testdir/test_autocmd.vim @ 34746:d537272fa503 v9.1.0251

patch 9.1.0251: Filetype test fails Commit: https://github.com/vim/vim/commit/8eb7523802cb51984e2202d08a4fbc1a2cd803c7 Author: zeertzjq <zeertzjq@outlook.com> Date: Mon Apr 1 14:46:20 2024 +0200 patch 9.1.0251: Filetype test fails Problem: Filetype test fails. Solution: Move detection by name before detection by extension. Improve TextChanged test and remove wrong test and fix a typo in a comment (zeertzjq). closes: #14373 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Mon, 01 Apr 2024 15:00:07 +0200
parents 159d598e6781
children 82e65843c29d
comparison
equal deleted inserted replaced
34745:300525584c40 34746:d537272fa503
3732 " TextChangedI should only trigger if change was done in Insert mode 3732 " TextChangedI should only trigger if change was done in Insert mode
3733 let g:autocmd_i = '' 3733 let g:autocmd_i = ''
3734 call feedkeys("yypi\<esc>", 'tnix') 3734 call feedkeys("yypi\<esc>", 'tnix')
3735 call assert_equal('', g:autocmd_i) 3735 call assert_equal('', g:autocmd_i)
3736 3736
3737 " TextChanged should only trigger if change was done in Normal mode
3738 let g:autocmd_n = ''
3739 call feedkeys("ibar\<esc>", 'tnix')
3740 call assert_equal('', g:autocmd_n)
3741
3742 " If change is a mix of Normal and Insert modes, TextChangedI should trigger 3737 " If change is a mix of Normal and Insert modes, TextChangedI should trigger
3743 func s:validate_mixed_textchangedi(keys) 3738 func s:validate_mixed_textchangedi(keys)
3744 call feedkeys("ifoo\<esc>", 'tnix') 3739 call feedkeys("ifoo\<esc>", 'tnix')
3745 let g:autocmd_i = '' 3740 let g:autocmd_i = ''
3746 let g:autocmd_n = '' 3741 let g:autocmd_n = ''
4530 call delete(expected) 4525 call delete(expected)
4531 endfunc 4526 endfunc
4532 4527
4533 " Test TextChangedI and TextChanged 4528 " Test TextChangedI and TextChanged
4534 func Test_Changed_ChangedI_2() 4529 func Test_Changed_ChangedI_2()
4530 " Run this test in a terminal because it requires running the main loop.
4535 CheckRunVimInTerminal 4531 CheckRunVimInTerminal
4536 call writefile(['one', 'two', 'three'], 'XTextChangedI2', 'D') 4532 call writefile(['one', 'two', 'three'], 'XTextChangedI2', 'D')
4537 let before =<< trim END 4533 let before =<< trim END
4538 autocmd TextChanged,TextChangedI * call writefile([b:changedtick], 'XTextChangedI3') 4534 let [g:autocmd_n, g:autocmd_i] = ['','']
4535
4536 func TextChangedAutocmd(char)
4537 let g:autocmd_{tolower(a:char)} = a:char .. b:changedtick
4538 call writefile([g:autocmd_n, g:autocmd_i], 'XTextChangedI3')
4539 endfunc
4540
4541 au TextChanged <buffer> :call TextChangedAutocmd('N')
4542 au TextChangedI <buffer> :call TextChangedAutocmd('I')
4543
4539 nnoremap <CR> o<Esc> 4544 nnoremap <CR> o<Esc>
4540 call writefile([], 'XTextChangedI3') 4545 call writefile([], 'XTextChangedI3')
4541 END 4546 END
4542 4547
4543 call writefile(before, 'Xinit', 'D') 4548 call writefile(before, 'Xinit', 'D')
4544 let buf = RunVimInTerminal('-S Xinit XtextChangedI2', {}) 4549 let buf = RunVimInTerminal('-S Xinit XtextChangedI2', {})
4550 call WaitForAssert({-> assert_true(filereadable('XTextChangedI3'))})
4545 call term_sendkeys(buf, "\<cr>") 4551 call term_sendkeys(buf, "\<cr>")
4546 call term_wait(buf) 4552 call WaitForAssert({-> assert_equal(['N4', ''], readfile('XTextChangedI3'))})
4547 call StopVimInTerminal(buf) 4553 call StopVimInTerminal(buf)
4548 call assert_equal(['4'], readfile('XTextChangedI3'))
4549 4554
4550 call delete('XTextChangedI3') 4555 call delete('XTextChangedI3')
4551 endfunc 4556 endfunc
4552 4557
4553 " Test that filetype detection still works when SwapExists autocommand sets 4558 " Test that filetype detection still works when SwapExists autocommand sets