Skip to content

Commit

Permalink
Handle more special keys properly
Browse files Browse the repository at this point in the history
Part of #232, Thanks to @rene-descartes2021
  • Loading branch information
liuchengxu committed Aug 10, 2023
1 parent e66e479 commit 5d6c28c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions autoload/which_key.vim
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ function! s:show_upper_level_mappings() abort
endfunction

function! s:getchar() abort
let input = ''
try
let c = getchar()
" Handle <C-C>
Expand All @@ -290,15 +289,8 @@ function! s:getchar() abort
return ''
endif

" Handle special keys, `:h keycode`
" <CR>, <Enter>
if c == 13
return '<CR>'
elseif c == 9
return '<Tab>'
endif
let input = which_key#char_handler#parse_raw(c)

let input .= which_key#char_handler#parse_raw(c)
if s:has_children(input)
while 1
if !which_key#char_handler#timeout_for_next_char()
Expand All @@ -308,6 +300,15 @@ function! s:getchar() abort
endif
endwhile
endif

" Convert special keys to internal data structure that use String as the
" key, e.g., "\<Tab>" => "<Tab>"
if has_key(s:KEYCODES, input)
let input = s:KEYCODES[input]
elseif has_key(s:MERGE_INTO, input)
let input = s:MERGE_INTO[input]
endif

return input
endfunction

Expand Down

0 comments on commit 5d6c28c

Please sign in to comment.