fix(vim): fix vim tab keybinding fallback. (#763)
parent
adb4bcd13f
commit
d47dac9041
|
|
@ -12,11 +12,16 @@ function! tabby#keybindings#Map()
|
|||
if !empty(mapcheck('<Tab>', 'i'))
|
||||
" fallback to the original <Tab> mapping
|
||||
let tab_maparg = maparg('<Tab>', 'i', 0, 1)
|
||||
" warp as function if rhs is expr, otherwise encode rhs as json
|
||||
let fallback_rhs = tab_maparg.expr ? '{ -> ' . tab_maparg.rhs . ' }' : substitute(json_encode(tab_maparg.rhs), '<', '\\<', 'g')
|
||||
" inject <SID>
|
||||
let fallback_rhs = substitute(fallback_rhs, '<SID>', "\<SNR>" . get(tab_maparg, 'sid') . '_', 'g')
|
||||
exec 'imap <script><silent><nowait><expr> <Tab> tabby#Accept(' . fallback_rhs . ')'
|
||||
if toupper(tab_maparg.rhs) == '<NOP>'
|
||||
" if the original <Tab> mapping is <nop>, no need to fallback
|
||||
imap <script><silent><nowait><expr> <Tab> tabby#Accept()
|
||||
else
|
||||
" warp as function if rhs is expr, otherwise encode rhs as json
|
||||
let fallback_rhs = tab_maparg.expr ? '{ -> ' . tab_maparg.rhs . ' }' : substitute(json_encode(tab_maparg.rhs), '<', '\\<', 'g')
|
||||
" inject <SID>
|
||||
let fallback_rhs = substitute(fallback_rhs, '<SID>', "\<SNR>" . get(tab_maparg, 'sid') . '_', 'g')
|
||||
exec 'imap ' . (get(tab_maparg, 'script') ? '<script>' : '') . '<silent><nowait><expr> <Tab> tabby#Accept(' . fallback_rhs . ')'
|
||||
endif
|
||||
else
|
||||
" fallback to input \t
|
||||
imap <script><silent><nowait><expr> <Tab> tabby#Accept("\t")
|
||||
|
|
|
|||
Loading…
Reference in New Issue