Skip to content
Myr

[vim] Use FZF_DEFAULT_COMMAND instead of STDIN pipe

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

So that fzf can finish immediately even when the input process doesn't handle SIGPIPE and keeps running. Fix #2481

authored by Junegunn Choi · committed by Junegunn Choi · parent 3f75a83 · Browse files · 1 file+19 added−9 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+19 added−9 removed

  • other:+19 added−9 removed

1 file+19 added−9 removed

modified:plugin/fzf.vim+19 added-9 removed
463 unmodified lines
464 let dict.dir = fnamemodify(dict.dir, ':p')465 endif466467 if has_key(dict, 'source')468 let source = dict.source468 let source = remove(dict, 'source')469 let type = type(source)470 if type == 1471 let prefix = '( '.source.' )|'471 let source_command = source472 elseif type == 3473 let temps.input = s:fzf_tempname()474 call writefile(source, temps.input)475 let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|'475 let source_command = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input)476 else477 throw 'Invalid source type'478 endif479 else480 let prefix = ''480 let source_command = ''481 endif482483 let prefer_tmux = get(g:, 'fzf_prefer_tmux', 0) || has_key(dict, 'tmux')484 let use_height = has_key(dict, 'down') && !has('gui_running') &&
14 unmodified lines
499 elseif use_term500 let optstr .= ' --no-height'501 endif502 let optstr .= s:border_opt(get(dict, 'window', 0))503 let prev_default_command = $FZF_DEFAULT_COMMAND504 if len(source_command)505 let $FZF_DEFAULT_COMMAND = source_command506 endif503 let command = prefix.(use_tmux ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result507 let command = (use_tmux ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result508509 if use_term510 return s:execute_term(dict, command, temps)511 endif
2 unmodified lines
514 \ : s:execute(dict, command, use_height, temps)515 call s:callback(dict, lines)516 return lines517finally518 if len(source_command)519 if len(prev_default_command)520 let $FZF_DEFAULT_COMMAND = prev_default_command521 else522 unlet $FZF_DEFAULT_COMMAND523 endif524 endif525 let [&shell, &shellslash, &shellcmdflag, &shellxquote] = [shell, shellslash, shellcmdflag, shellxquote]526endtry527endfunction528
21 unmodified lines
550 break551 endif552 endfor553 endif543 return printf('LINES=%d COLUMNS=%d %s %s %s --',544 \ &lines, &columns, fzf#shellescape(s:fzf_tmux), size, (has_key(a:dict, 'source') ? '' : '-'))554 return printf('LINES=%d COLUMNS=%d %s %s - --',555 \ &lines, &columns, fzf#shellescape(s:fzf_tmux), size)556endfunction557558function! s:splittable(dict)559 return s:present(a:dict, 'up', 'down') && &lines > 15 ||
121 unmodified lines
681 let command = 'cmd.exe /C '.fzf#shellescape('set "TERM=" & start /WAIT sh -c '.shellscript)682 let a:temps.shellscript = shellscript683 endif684 if a:use_height674 let stdin = has_key(a:dict, 'source') ? '' : '< /dev/tty'675 call system(printf('tput cup %d > /dev/tty; tput cnorm > /dev/tty; %s %s 2> /dev/tty', &lines, command, stdin))685 call system(printf('tput cup %d > /dev/tty; tput cnorm > /dev/tty; %s < /dev/tty 2> /dev/tty', &lines, command))686 else687 execute 'silent !'.command688 endif689 let exit_status = v:shell_error
356 unmodified lines