mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
vim-patch:9.1.0251: Filetype test fails (#28142)
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: vim/vim#14373
8eb7523802
The changes to filetype.vim are N/A since Nvim always prefers filename
matches to extension matches.
This commit is contained in:
parent
381806729d
commit
4a6b4b00cb
@ -367,7 +367,7 @@ static void insert_enter(InsertState *s)
|
|||||||
// ins_redraw() triggers TextChangedI only when no characters
|
// ins_redraw() triggers TextChangedI only when no characters
|
||||||
// are in the typeahead buffer, so reset curbuf->b_last_changedtick
|
// are in the typeahead buffer, so reset curbuf->b_last_changedtick
|
||||||
// if the TextChangedI was not blocked by char_avail() (e.g. using :norm!)
|
// if the TextChangedI was not blocked by char_avail() (e.g. using :norm!)
|
||||||
// and the TextChangedI autocommand has been triggered
|
// and the TextChangedI autocommand has been triggered.
|
||||||
if (!char_avail() && curbuf->b_last_changedtick_i == buf_get_changedtick(curbuf)) {
|
if (!char_avail() && curbuf->b_last_changedtick_i == buf_get_changedtick(curbuf)) {
|
||||||
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
|
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
|
||||||
}
|
}
|
||||||
|
@ -194,17 +194,14 @@ end)
|
|||||||
-- oldtest: Test_Changed_ChangedI_2()
|
-- oldtest: Test_Changed_ChangedI_2()
|
||||||
it('TextChanged is triggered after mapping that enters & exits Insert mode', function()
|
it('TextChanged is triggered after mapping that enters & exits Insert mode', function()
|
||||||
exec([[
|
exec([[
|
||||||
let [g:autocmd_i, g:autocmd_n] = ['','']
|
let [g:autocmd_n, g:autocmd_i] = ['','']
|
||||||
|
|
||||||
func! TextChangedAutocmdI(char)
|
func TextChangedAutocmd(char)
|
||||||
let g:autocmd_{tolower(a:char)} = a:char .. b:changedtick
|
let g:autocmd_{tolower(a:char)} = a:char .. b:changedtick
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
augroup Test_TextChanged
|
au TextChanged <buffer> :call TextChangedAutocmd('N')
|
||||||
au!
|
au TextChangedI <buffer> :call TextChangedAutocmd('I')
|
||||||
au TextChanged <buffer> :call TextChangedAutocmdI('N')
|
|
||||||
au TextChangedI <buffer> :call TextChangedAutocmdI('I')
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
nnoremap <CR> o<Esc>
|
nnoremap <CR> o<Esc>
|
||||||
]])
|
]])
|
||||||
|
@ -3530,11 +3530,6 @@ func Test_Changed_ChangedI()
|
|||||||
call feedkeys("yypi\<esc>", 'tnix')
|
call feedkeys("yypi\<esc>", 'tnix')
|
||||||
call assert_equal('', g:autocmd_i)
|
call assert_equal('', g:autocmd_i)
|
||||||
|
|
||||||
" TextChanged should only trigger if change was done in Normal mode
|
|
||||||
let g:autocmd_n = ''
|
|
||||||
call feedkeys("ibar\<esc>", 'tnix')
|
|
||||||
call assert_equal('', g:autocmd_n)
|
|
||||||
|
|
||||||
" If change is a mix of Normal and Insert modes, TextChangedI should trigger
|
" If change is a mix of Normal and Insert modes, TextChangedI should trigger
|
||||||
func s:validate_mixed_textchangedi(keys)
|
func s:validate_mixed_textchangedi(keys)
|
||||||
call feedkeys("ifoo\<esc>", 'tnix')
|
call feedkeys("ifoo\<esc>", 'tnix')
|
||||||
@ -3959,20 +3954,30 @@ endfunc
|
|||||||
|
|
||||||
" Test TextChangedI and TextChanged
|
" Test TextChangedI and TextChanged
|
||||||
func Test_Changed_ChangedI_2()
|
func Test_Changed_ChangedI_2()
|
||||||
|
" Run this test in a terminal because it requires running the main loop.
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
call writefile(['one', 'two', 'three'], 'XTextChangedI2', 'D')
|
call writefile(['one', 'two', 'three'], 'XTextChangedI2', 'D')
|
||||||
let before =<< trim END
|
let before =<< trim END
|
||||||
autocmd TextChanged,TextChangedI * call writefile([b:changedtick], 'XTextChangedI3')
|
let [g:autocmd_n, g:autocmd_i] = ['','']
|
||||||
|
|
||||||
|
func TextChangedAutocmd(char)
|
||||||
|
let g:autocmd_{tolower(a:char)} = a:char .. b:changedtick
|
||||||
|
call writefile([g:autocmd_n, g:autocmd_i], 'XTextChangedI3')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
au TextChanged <buffer> :call TextChangedAutocmd('N')
|
||||||
|
au TextChangedI <buffer> :call TextChangedAutocmd('I')
|
||||||
|
|
||||||
nnoremap <CR> o<Esc>
|
nnoremap <CR> o<Esc>
|
||||||
call writefile([], 'XTextChangedI3')
|
call writefile([], 'XTextChangedI3')
|
||||||
END
|
END
|
||||||
|
|
||||||
call writefile(before, 'Xinit', 'D')
|
call writefile(before, 'Xinit', 'D')
|
||||||
let buf = RunVimInTerminal('-S Xinit XtextChangedI2', {})
|
let buf = RunVimInTerminal('-S Xinit XtextChangedI2', {})
|
||||||
|
call WaitForAssert({-> assert_true(filereadable('XTextChangedI3'))})
|
||||||
call term_sendkeys(buf, "\<cr>")
|
call term_sendkeys(buf, "\<cr>")
|
||||||
call term_wait(buf)
|
call WaitForAssert({-> assert_equal(['N4', ''], readfile('XTextChangedI3'))})
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call assert_equal(['4'], readfile('XTextChangedI3'))
|
|
||||||
|
|
||||||
call delete('XTextChangedI3')
|
call delete('XTextChangedI3')
|
||||||
endfunc
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user