forked from aniani/vim
patch 9.0.0956: terminal tests fail when using key with modifier
Problem: Terminal tests fail when using key with modifier. Solution: Use the modifyOtherKeys encoding when using RunVimInTerminal().
This commit is contained in:
@@ -189,4 +189,43 @@ func Term_getlines(buf, lines)
|
|||||||
return join(map(a:lines, 'term_getline(a:buf, v:val)'), '')
|
return join(map(a:lines, 'term_getline(a:buf, v:val)'), '')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" When using RunVimInTerminal() we expect modifyOtherKeys level 2 to be enabled
|
||||||
|
" automatically. The key + modifier Escape codes must then use the
|
||||||
|
" modifyOtherKeys encoding. They are recognized anyway, thus it's safer to use
|
||||||
|
" than the raw code.
|
||||||
|
|
||||||
|
" Return the modifyOtherKeys level 2 encoding for "key" with "modifier"
|
||||||
|
" (number value, e.g. CTRL is 5).
|
||||||
|
func GetEscCodeCSI27(key, modifier)
|
||||||
|
let key = printf("%d", char2nr(a:key))
|
||||||
|
let mod = printf("%d", a:modifier)
|
||||||
|
return "\<Esc>[27;" .. mod .. ';' .. key .. '~'
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Return the modifyOtherKeys level 2 encoding for "key" with "modifier"
|
||||||
|
" (character value, e.g. CTRL is "C").
|
||||||
|
func GetEscCodeWithModifier(modifier, key)
|
||||||
|
let modifier = get({'C': 5}, a:modifier, '')
|
||||||
|
if modifier == ''
|
||||||
|
echoerr 'Unknown modifier: ' .. a:modifier
|
||||||
|
endif
|
||||||
|
return GetEscCodeCSI27(a:key, modifier)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Return the kitty keyboard protocol encoding for "key" with "modifier"
|
||||||
|
" (number value, e.g. CTRL is 5).
|
||||||
|
func GetEscCodeCSIu(key, modifier)
|
||||||
|
let key = printf("%d", char2nr(a:key))
|
||||||
|
let mod = printf("%d", a:modifier)
|
||||||
|
return "\<Esc>[" .. key .. ';' .. mod .. 'u'
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Return the kitty keyboard protocol encoding for "key" without a modifier.
|
||||||
|
" Used for the Escape key.
|
||||||
|
func GetEscCodeCSIuWithoutModifier(key)
|
||||||
|
let key = printf("%d", char2nr(a:key))
|
||||||
|
return "\<Esc>[" .. key .. 'u'
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -584,7 +584,7 @@ func Test_expr_map_restore_cursor()
|
|||||||
END
|
END
|
||||||
call writefile(lines, 'XtestExprMap', 'D')
|
call writefile(lines, 'XtestExprMap', 'D')
|
||||||
let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
|
let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
|
||||||
call term_sendkeys(buf, "\<C-B>")
|
call term_sendkeys(buf, GetEscCodeWithModifier('C', 'B'))
|
||||||
call VerifyScreenDump(buf, 'Test_map_expr_1', {})
|
call VerifyScreenDump(buf, 'Test_map_expr_1', {})
|
||||||
|
|
||||||
" clean up
|
" clean up
|
||||||
|
@@ -4,6 +4,7 @@ source check.vim
|
|||||||
CheckFeature popupwin
|
CheckFeature popupwin
|
||||||
|
|
||||||
source screendump.vim
|
source screendump.vim
|
||||||
|
source term_util.vim
|
||||||
|
|
||||||
func Test_simple_popup()
|
func Test_simple_popup()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
@@ -3722,7 +3723,9 @@ func Test_popupmenu_masking()
|
|||||||
let buf = RunVimInTerminal('-S XtestPopupmenuMasking', #{rows: 14})
|
let buf = RunVimInTerminal('-S XtestPopupmenuMasking', #{rows: 14})
|
||||||
call TermWait(buf, 25)
|
call TermWait(buf, 25)
|
||||||
|
|
||||||
call term_sendkeys(buf, "A\<C-X>\<C-U>\<C-A>")
|
call term_sendkeys(buf, "A" .. GetEscCodeWithModifier('C', 'X')
|
||||||
|
\ .. GetEscCodeWithModifier('C', 'U')
|
||||||
|
\ .. GetEscCodeWithModifier('C', 'A'))
|
||||||
call VerifyScreenDump(buf, 'Test_popupwin_popupmenu_masking_1', {})
|
call VerifyScreenDump(buf, 'Test_popupwin_popupmenu_masking_1', {})
|
||||||
|
|
||||||
call term_sendkeys(buf, "\<Esc>")
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
|
@@ -2094,23 +2094,6 @@ func Test_list_builtin_terminals()
|
|||||||
call StopVimInTerminal('')
|
call StopVimInTerminal('')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func GetEscCodeCSI27(key, modifier)
|
|
||||||
let key = printf("%d", char2nr(a:key))
|
|
||||||
let mod = printf("%d", a:modifier)
|
|
||||||
return "\<Esc>[27;" .. mod .. ';' .. key .. '~'
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func GetEscCodeCSIu(key, modifier)
|
|
||||||
let key = printf("%d", char2nr(a:key))
|
|
||||||
let mod = printf("%d", a:modifier)
|
|
||||||
return "\<Esc>[" .. key .. ';' .. mod .. 'u'
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func GetEscCodeCSIuWithoutModifier(key)
|
|
||||||
let key = printf("%d", char2nr(a:key))
|
|
||||||
return "\<Esc>[" .. key .. 'u'
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
" This checks the CSI sequences when in modifyOtherKeys mode.
|
" This checks the CSI sequences when in modifyOtherKeys mode.
|
||||||
" The mode doesn't need to be enabled, the codes are always detected.
|
" The mode doesn't need to be enabled, the codes are always detected.
|
||||||
func RunTest_modifyOtherKeys(func)
|
func RunTest_modifyOtherKeys(func)
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
956,
|
||||||
/**/
|
/**/
|
||||||
955,
|
955,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user