diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2015-09-27 16:26:40 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-09-27 16:26:40 +0900 |
| commit | 862da2c0b1ea2d607f9e626ee3ee8508a583bbc1 (patch) | |
| tree | 2e39af662ca8b77f76fa2e7d49fc4c56b1b469ab | |
| parent | 545370d2b3d8e2a18166f8e4b5def10475769429 (diff) | |
| download | fzf-862da2c0b1ea2d607f9e626ee3ee8508a583bbc1.tar.gz | |
[vim] Consistent exit status handling
| -rw-r--r-- | plugin/fzf.vim | 32 |
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 |
