test(old): emulate test_override('char_avail') using FFI

Add a non-static variable for this, otherwise it'll be really hacky.
This avoid having to rewrite many incsearch tests in Lua.
This commit is contained in:
zeertzjq
2025-07-03 21:23:26 +08:00
parent bfffe0d214
commit c925e7b8ba
9 changed files with 106 additions and 107 deletions

View File

@@ -724,15 +724,14 @@ func Test_edit_CTRL_K()
let v:testing = 0
endtry
if exists('*test_override')
call test_override("char_avail", 1)
set showcmd
%d
call feedkeys("A\<c-k>a:\<esc>", 'tnix')
call assert_equal(['ä'], getline(1, '$'))
call test_override("char_avail", 0)
set noshowcmd
endif
call Ntest_override("char_avail", 1)
set showcmd
%d
call feedkeys("A\<c-k>a:\<esc>", 'tnix')
call assert_equal(['ä'], getline(1, '$'))
call Ntest_override("char_avail", 0)
set noshowcmd
bw!
endfunc
@@ -764,9 +763,9 @@ func Test_edit_CTRL_L()
call assert_equal(['one', 'two', 'three', 'three', "\<c-l>\<c-p>\<c-n>", '', ''], getline(1, '$'))
set complete&
%d
if has("conceal") && has("syntax") && !has("nvim")
if has("conceal") && has("syntax")
call setline(1, ['foo', 'bar', 'foobar'])
call test_override("char_avail", 1)
call Ntest_override("char_avail", 1)
set conceallevel=2 concealcursor=n
syn on
syn match ErrorMsg "^bar"
@@ -782,7 +781,7 @@ func Test_edit_CTRL_L()
call assert_equal(['foo', 'bar ', 'foobar'], getline(1, '$'))
call assert_equal(1, g:change)
call test_override("char_avail", 0)
call Ntest_override("char_avail", 0)
call clearmatches()
syn off
au! TextChangedI
@@ -1157,7 +1156,7 @@ func Test_edit_CTRL_V()
" force some redraws
set showmode showcmd
" call test_override('char_avail', 1)
call Ntest_override('char_avail', 1)
call feedkeys("A\<c-v>\<c-n>\<c-v>\<c-l>\<c-v>\<c-b>\<esc>", 'tnix')
call assert_equal(["abc\x0e\x0c\x02"], getline(1, '$'))
@@ -1172,7 +1171,7 @@ func Test_edit_CTRL_V()
endif
set noshowmode showcmd
" call test_override('char_avail', 0)
call Ntest_override('char_avail', 0)
" No modifiers should be applied to the char typed using i_CTRL-V_digit.
call feedkeys(":append\<CR>\<C-V>76c\<C-V>76\<C-F2>\<C-V>u3c0j\<C-V>u3c0\<M-F3>\<CR>.\<CR>", 'tnix')