Skip to content

Commit 799491e

Browse files
committed
Fix #237
1 parent d005409 commit 799491e

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

autoload/EasyMotion.vim

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -471,16 +471,28 @@ function! s:SetLines(lines, key) " {{{
471471
endfunction " }}}
472472

473473
" -- Get characters from user input ------
474-
function! s:GetChar() " {{{
475-
let char = getchar()
476-
if char == 27 || char == 3
477-
" Escape or <C-c> key pressed
478-
redraw
479-
call s:Message('Cancelled')
480-
return ''
481-
endif
482-
return nr2char(char)
483-
endfunction " }}}
474+
function! s:GetChar(...) abort "{{{
475+
let mode = get(a:, 1, 0)
476+
while 1
477+
" Workaround for https://github.com/osyo-manga/vital-over/issues/53
478+
try
479+
let char = call('getchar', a:000)
480+
catch /^Vim:Interrupt$/
481+
let char = 3 " <C-c>
482+
endtry
483+
if char == 27 || char == 3
484+
" Escape or <C-c> key pressed
485+
redraw
486+
call s:Message('Cancelled')
487+
return ''
488+
endif
489+
" Workaround for the <expr> mappings
490+
if string(char) !=# "\x80\xfd`"
491+
return mode == 1 ? !!char
492+
\ : type(char) == type(0) ? nr2char(char) : char
493+
endif
494+
endwhile
495+
endfunction "}}}
484496

485497
" -- Find Motion Helper ------------------
486498
function! s:findMotion(num_strokes, direction) "{{{

0 commit comments

Comments
 (0)