Improve exception handling
This commit is contained in:
parent
fea0d68d5a
commit
1864b1d3fd
@ -223,46 +223,46 @@
|
|||||||
" Highlight source
|
" Highlight source
|
||||||
let target_hl_id = matchadd(g:EasyMotion_target_hl, join(hl_coords, '\|'), 1)
|
let target_hl_id = matchadd(g:EasyMotion_target_hl, join(hl_coords, '\|'), 1)
|
||||||
|
|
||||||
" Set lines with markers
|
try
|
||||||
call s:SetLines(lines_items, 'marker')
|
" Set lines with markers
|
||||||
|
call s:SetLines(lines_items, 'marker')
|
||||||
|
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
" Get target/group character
|
" Get target/group character
|
||||||
if single_group
|
if single_group
|
||||||
call s:Prompt('Target character')
|
call s:Prompt('Target character')
|
||||||
else
|
else
|
||||||
call s:Prompt('Group character')
|
call s:Prompt('Group character')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let input_char = s:GetChar()
|
let char = s:GetChar()
|
||||||
|
finally
|
||||||
|
" Restore original lines
|
||||||
|
call s:SetLines(lines_items, 'orig')
|
||||||
|
|
||||||
redraw
|
" Un-highlight code
|
||||||
|
call matchdelete(target_hl_id)
|
||||||
|
|
||||||
" Restore original lines
|
redraw
|
||||||
call s:SetLines(lines_items, 'orig')
|
endtry
|
||||||
|
|
||||||
" Un-highlight code
|
|
||||||
call matchdelete(target_hl_id)
|
|
||||||
|
|
||||||
redraw
|
|
||||||
|
|
||||||
" Check that we have an input char
|
" Check that we have an input char
|
||||||
if empty(input_char)
|
if empty(char)
|
||||||
throw 'Cancelled'
|
throw 'Cancelled'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Check if the input char is valid
|
" Check if the input char is valid
|
||||||
if ! has_key(s:key_to_index, input_char) || s:key_to_index[input_char] >= targets_len
|
if ! has_key(s:key_to_index, char) || s:key_to_index[char] >= targets_len
|
||||||
throw 'Invalid target'
|
throw 'Invalid target'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if single_group
|
if single_group
|
||||||
" Return target coordinates
|
" Return target coordinates
|
||||||
return a:groups[0][s:key_to_index[input_char]]
|
return a:groups[0][s:key_to_index[char]]
|
||||||
else
|
else
|
||||||
" Prompt for target character
|
" Prompt for target character
|
||||||
return s:PromptUser([a:groups[s:key_to_index[input_char]]])
|
return s:PromptUser([a:groups[s:key_to_index[char]]])
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
function! s:EasyMotion(regexp, direction, visualmode) " {{{
|
function! s:EasyMotion(regexp, direction, visualmode) " {{{
|
||||||
@ -353,7 +353,7 @@
|
|||||||
call setpos('.', [0, coords[0], coords[1]])
|
call setpos('.', [0, coords[0], coords[1]])
|
||||||
|
|
||||||
call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
|
call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
|
||||||
catch /.*/
|
catch
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
" Show exception message
|
" Show exception message
|
||||||
@ -366,18 +366,16 @@
|
|||||||
call setpos('.', [0, orig_pos[0], orig_pos[1]])
|
call setpos('.', [0, orig_pos[0], orig_pos[1]])
|
||||||
endif
|
endif
|
||||||
finally
|
finally
|
||||||
redraw
|
|
||||||
|
|
||||||
" Remove shading
|
|
||||||
if g:EasyMotion_do_shade && exists('shade_hl_id')
|
|
||||||
call matchdelete(shade_hl_id)
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Restore properties
|
" Restore properties
|
||||||
call s:VarReset('&scrolloff')
|
call s:VarReset('&scrolloff')
|
||||||
call s:VarReset('&modified')
|
call s:VarReset('&modified')
|
||||||
call s:VarReset('&modifiable')
|
call s:VarReset('&modifiable')
|
||||||
call s:VarReset('&readonly')
|
call s:VarReset('&readonly')
|
||||||
|
|
||||||
|
" Remove shading
|
||||||
|
if g:EasyMotion_do_shade && exists('shade_hl_id')
|
||||||
|
call matchdelete(shade_hl_id)
|
||||||
|
endif
|
||||||
endtry
|
endtry
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
" }}}
|
" }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user