Skip to content
Myr

[vim] Handle writefile() failure gracefully

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #2676

authored by Junegunn Choi · committed by Junegunn Choi · parent ce9af68 · Browse files · 1 file+11 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−5 removed

  • other:+11 added−5 removed

1 file+11 added−5 removed

modified:plugin/fzf.vim+11 added-5 removed
442 unmodified lines
443 endif444 return [shell, shellslash, shellcmdflag, shellxquote]445endfunction446447function! s:writefile(...)448 if call('writefile', a:000) == -1449 throw 'Failed to write temporary file. Check if you can write to the path tempname() returns.'450 endif451endfunction452453function! fzf#run(...) abort454try455 let [shell, shellslash, shellcmdflag, shellxquote] = s:use_sh()456
19 unmodified lines
476 if type == 1477 let source_command = source478 elseif type == 3479 let temps.input = s:fzf_tempname()474 call writefile(source, temps.input)480 call s:writefile(source, temps.input)481 let source_command = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input)482 else483 throw 'Invalid source type'484 endif
35 unmodified lines
520 \ : s:execute(dict, command, use_height, temps)521 call s:callback(dict, lines)522 return lines523finally518 if len(source_command)524 if exists('source_command') && len(source_command)525 if len(prev_default_command)526 let $FZF_DEFAULT_COMMAND = prev_default_command527 else528 let $FZF_DEFAULT_COMMAND = ''
136 unmodified lines
665 let command = escaped666 endif667 if s:is_win668 let batchfile = s:fzf_tempname().'.bat'663 call writefile(s:wrap_cmds(command), batchfile)669 call s:writefile(s:wrap_cmds(command), batchfile)670 let command = batchfile671 let a:temps.batchfile = batchfile672 if has('nvim')673 let fzf = {}
9 unmodified lines
683 return []684 endif685 elseif has('win32unix') && $TERM !=# 'cygwin'686 let shellscript = s:fzf_tempname()681 call writefile([command], shellscript)687 call s:writefile([command], shellscript)688 let command = 'cmd.exe /C '.fzf#shellescape('set "TERM=" & start /WAIT sh -c '.shellscript)689 let a:temps.shellscript = shellscript690 endif691 if a:use_height
190 unmodified lines
882 try883 call s:pushd(a:dict)884 if s:is_win885 let fzf.temps.batchfile = s:fzf_tempname().'.bat'880 call writefile(s:wrap_cmds(a:command), fzf.temps.batchfile)886 call s:writefile(s:wrap_cmds(a:command), fzf.temps.batchfile)887 let command = fzf.temps.batchfile888 else889 let command = a:command890 endif
164 unmodified lines