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