Fix #494 - _fzf_complete hangs on zsh when not using tmux pane
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent e57182c · Browse files · 2 files·+45 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+45 added−17 removed
- tests:+34 added−15 removed
- other:+11 added−2 removed
Provenance
- Commit
a568120- Tree
30f9d8e- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
e57182c
2 files changed+45 added−17 removed
modified:shell/completion.zsh+11 added-2 removed
77 unmodified lines78798081828384858687888389909192939495969798919910010110210310410510610710883 unmodified lines77 unmodified lines __fzf_generic_path_completion "$1" "$2" _fzf_compgen_dir \ "" "/" ""}
_fzf_feed_fifo() ( rm -f "$fifo" mkfifo "$fifo" cat <&0 > "$fifo" &)
_fzf_complete() { local fzf_opts lbuf fzf matches post local fifo fzf_opts lbuf fzf matches post fifo="${TMPDIR:-/tmp}/fzf-complete-fifo-$$" fzf_opts=$1 lbuf=$2 post="${funcstack[2]}_post" type $post > /dev/null 2>&1 || post=cat
[ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"
_fzf_feed_fifo "$fifo" matches=$(cat | ${=fzf} ${=FZF_COMPLETION_OPTS} ${=fzf_opts} -q "${(Q)prefix}" | $post | tr '\n' ' ') matches=$(cat "$fifo" | ${=fzf} ${=FZF_COMPLETION_OPTS} ${=fzf_opts} -q "${(Q)prefix}" | $post | tr '\n' ' ') if [ -n "$matches" ]; then LBUFFER="$lbuf$matches" fi zle redisplay rm -f "$fifo"}
_fzf_complete_telnet() { _fzf_complete '+m' "$@" < <(83 unmodified linesmodified:test/test_go.rb+34 added-15 removed
1138 unmodified lines1139 1140 private1141 def writelines path, lines1142 File.unlink path while File.exists? path1143- File.open(path, 'w') { |f| f << lines.join($/) }1143+ File.open(path, 'w') { |f| f << lines.join($/) + $/ }1144 end1145 end1146 1147 module TestShell206 unmodified lines1354 tmux.until do |lines|1355 tmux.send_keys 'C-L'1356 lines[-1] == "kill #{pid}"1357 end1358-1359- def test_custom_completion1360- tmux.send_keys '_fzf_compgen_path() { echo "\$1"; seq 10; }', :Enter1361- tmux.prepare1362- tmux.send_keys 'ls /tmp/**', :Tab, pane: 01363- tmux.until(1) { |lines| lines.item_count == 11 }1364- tmux.send_keys :BTab, :BTab, :BTab1365- tmux.until(1) { |lines| lines[-2].include? '(3)' }1366- tmux.send_keys :Enter1367- tmux.until do |lines|1368- tmux.send_keys 'C-L'1369- lines[-1] == "ls /tmp 1 2"1370- end1371- end1358 ensure1359 Process.kill 'KILL', pid.to_i rescue nil if pid1360 end1361+1362+ def test_custom_completion1363+ tmux.send_keys '_fzf_compgen_path() { echo "\$1"; seq 10; }', :Enter1364+ tmux.prepare1365+ tmux.send_keys 'ls /tmp/**', :Tab, pane: 01366+ tmux.until(1) { |lines| lines.item_count == 11 }1367+ tmux.send_keys :BTab, :BTab, :BTab1368+ tmux.until(1) { |lines| lines[-2].include? '(3)' }1369+ tmux.send_keys :Enter1370+ tmux.until do |lines|1371+ tmux.send_keys 'C-L'1372+ lines[-1] == "ls /tmp 1 2"1373+ end1374+ end1375+1376+ def test_unset_completion1377+ tmux.send_keys 'export FOO=BAR', :Enter1378+ tmux.prepare1379+1380+ # Using tmux1381+ tmux.send_keys 'unset FOO**', :Tab, pane: 01382+ tmux.until(1) { |lines| lines[-2].include? ' 1/' }1383+ tmux.send_keys :Enter1384+ tmux.until { |lines| lines[-1] == 'unset FOO' }1385+ tmux.send_keys 'C-c'1386+1387+ # FZF_TMUX=01388+ new_shell1389+ tmux.send_keys 'unset FOO**', :Tab1390+ tmux.until { |lines| lines[-2].include? ' 1/' }1391+ tmux.send_keys :Enter1392+ tmux.until { |lines| lines[-1] == 'unset FOO' }1393+ end1394 end1395 1396 class TestBash < TestBase1397 include TestShell50 unmodified lines