fix(vim): fix <Tab> keybinding when try to fallback to original one. (#616)

* fix(vim): fix <Tab> keybinding when try to fallback to original one.

* fix: fix typo.
r0.4
Zhiming Ma 2023-10-23 13:05:10 +08:00 committed by GitHub
parent 573196b9d9
commit ae6e6bfe37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -12,8 +12,8 @@ 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
let fallback_rhs = tab_maparg.expr ? '{ -> ' . tab_maparg.rhs . ' }' : tab_maparg.rhs
" 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 . ')'