mirror of
https://github.com/preservim/vim-pencil.git
synced 2025-11-14 04:43:47 -05:00
Fix Mapkey to return queried key instead of 0 if no match
This commit is contained in:
@@ -522,20 +522,17 @@ fun! s:doModelines() abort
|
|||||||
en
|
en
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
" Pass in a key sequence and the first letter of a vim mode. Returns key
|
||||||
|
" mapping mapped to it in that mode, else the original key sequence if none.
|
||||||
function! Mapkey (keys, mode) abort
|
function! Mapkey (keys, mode) abort
|
||||||
" Pass in a key sequence and the first letter of a vim mode.
|
redir => mappings | silent! map | redir END
|
||||||
" Returns key mapping mapped to it in that mode, else 0 if none.
|
for map in split(mappings, '\n')
|
||||||
" example:
|
let seq = matchstr(map, '\s\+\zs\S*')
|
||||||
" :nnoremap <Tab> :bn<CR>
|
if maparg(seq, a:mode) == a:keys
|
||||||
" :call Mapkey(':bn<CR>', 'n')
|
return seq
|
||||||
" " returns <Tab>
|
endif
|
||||||
redir => mappings | silent! map | redir END
|
endfor
|
||||||
for map in split(mappings, '\n')
|
return a:keys
|
||||||
let seq = matchstr(map, '\s\+\zs\S*')
|
|
||||||
if maparg(seq, a:mode) == a:keys
|
|
||||||
return seq
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim:ts=2:sw=2:sts=2
|
" vim:ts=2:sw=2:sts=2
|
||||||
|
|||||||
Reference in New Issue
Block a user