Merge pull request #506 from justinmk/fixvarmismatch

[vim] s:callback: Always return list.
This commit is contained in:
Junegunn Choi 2016-02-23 15:39:53 +09:00
commit 85751966e9

View File

@ -239,7 +239,7 @@ function! s:exit_handler(code, command, ...)
return 1 return 1
endfunction endfunction
function! s:execute(dict, command, temps) function! s:execute(dict, command, temps) abort
call s:pushd(a:dict) call s:pushd(a:dict)
silent! !clear 2> /dev/null silent! !clear 2> /dev/null
let escaped = escape(substitute(a:command, '\n', '\\n', 'g'), '%#') let escaped = escape(substitute(a:command, '\n', '\\n', 'g'), '%#')
@ -255,7 +255,7 @@ function! s:execute(dict, command, temps)
return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : [] return s:exit_handler(v:shell_error, command) ? s:callback(a:dict, a:temps) : []
endfunction endfunction
function! s:execute_tmux(dict, command, temps) function! s:execute_tmux(dict, command, temps) abort
let command = a:command let command = a:command
if s:pushd(a:dict) if s:pushd(a:dict)
" -c '#{pane_current_path}' is only available on tmux 1.9 or above " -c '#{pane_current_path}' is only available on tmux 1.9 or above
@ -320,7 +320,7 @@ function! s:split(dict)
endtry endtry
endfunction endfunction
function! s:execute_term(dict, command, temps) function! s:execute_term(dict, command, temps) abort
call s:split(a:dict) call s:split(a:dict)
let fzf = { 'buf': bufnr('%'), 'dict': a:dict, 'temps': a:temps, 'name': 'FZF' } let fzf = { 'buf': bufnr('%'), 'dict': a:dict, 'temps': a:temps, 'name': 'FZF' }
@ -369,11 +369,10 @@ function! s:execute_term(dict, command, temps)
return [] return []
endfunction endfunction
function! s:callback(dict, temps) function! s:callback(dict, temps) abort
let lines = []
try try
if !filereadable(a:temps.result) if filereadable(a:temps.result)
let lines = []
else
let lines = readfile(a:temps.result) let lines = readfile(a:temps.result)
if has_key(a:dict, 'sink') if has_key(a:dict, 'sink')
for line in lines for line in lines
@ -392,12 +391,12 @@ try
for tf in values(a:temps) for tf in values(a:temps)
silent! call delete(tf) silent! call delete(tf)
endfor endfor
return lines
catch catch
if stridx(v:exception, ':E325:') < 0 if stridx(v:exception, ':E325:') < 0
echoerr v:exception echoerr v:exception
endif endif
finally
return lines
endtry endtry
endfunction endfunction