summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/fzf.vim32
1 files changed, 16 insertions, 16 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 4aefb4cd..d37e53b2 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -222,6 +222,19 @@ endfunction
unlet! s:launcher
let s:launcher = function('s:xterm_launcher')
+function! s:exit_handler(code, command, ...)
+ if a:code == 130
+ return 0
+ elseif a:code > 1
+ call s:error('Error running ' . a:command)
+ if !empty(a:000)
+ sleep
+ endif
+ return 0
+ endif
+ return 1
+endfunction
+
function! s:execute(dict, command, temps)
call s:pushd(a:dict)
silent! !clear 2> /dev/null
@@ -235,14 +248,7 @@ function! s:execute(dict, command, temps)
endif
execute 'silent !'.command
redraw!
- if v:shell_error == 0 || v:shell_error == 1
- return s:callback(a:dict, a:temps)
- " Do not print error message on exit status 130 (interrupt)
- elseif v:shell_error == 130
- return []
- else
- call s:error('Error running ' . command)
- endif
+ return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : []
endfunction
function! s:execute_tmux(dict, command, temps)
@@ -254,11 +260,7 @@ function! s:execute_tmux(dict, command, temps)
call system(command)
redraw!
- if v:shell_error == 2
- call s:error('Error running ' . command)
- return []
- endif
- return s:callback(a:dict, a:temps)
+ return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : []
endfunction
function! s:calc_size(max, val, dict)
@@ -334,9 +336,7 @@ function! s:execute_term(dict, command, temps)
endif
endif
- if a:code == 2
- call s:error('Error running ' . s:command)
- sleep
+ if !s:exit_handler(a:code, s:command, 1)
return
endif