From 7c447bbdc7adb1fe0c848e171780f68cacf3e80e Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Fri, 28 Feb 2020 02:47:13 -0700 Subject: [bash] Start C-r search with current command line (#1886) Restore the original line when search is aborted. Add --query "$READLINE_LINE" and fall back to the current behavior pre Bash 4. Co-authored-by: Junegunn Choi --- test/test_go.rb | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/test_go.rb b/test/test_go.rb index d2d31532..41aaf8d5 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -84,8 +84,6 @@ class Shell end class Tmux - TEMPNAME = '/tmp/fzf-test.txt' - attr_reader :win def initialize(shell = :bash) @@ -129,12 +127,7 @@ class Tmux end def capture(pane = 0) - File.unlink TEMPNAME while File.exist? TEMPNAME - wait do - go("capture-pane -t #{win}.#{pane} \\; save-buffer #{TEMPNAME} 2> /dev/null") - $CHILD_STATUS.exitstatus.zero? - end - File.read(TEMPNAME).split($INPUT_RECORD_SEPARATOR).reverse.drop_while(&:empty?).reverse + go("capture-pane -p -t #{win}.#{pane}") end def until(refresh = false, pane = 0) @@ -1738,7 +1731,8 @@ end module TestShell def setup - super + @tmux = Tmux.new shell + tmux.prepare end def teardown @@ -1855,6 +1849,16 @@ module TestShell tmux.until { |lines| lines[-1] == '3rd' } end + def test_ctrl_r_abort + skip "doesn't restore the original line when search is aborted pre Bash 4" if shell == :bash && /(?<= version )\d+/.match(`#{Shell.bash} --version`).to_s.to_i < 4 + tmux.send_keys 'foo' + tmux.until { |lines| lines[-1].start_with? 'foo' } + tmux.send_keys 'C-r' + tmux.until { |lines| lines[-1].start_with? '>' } + tmux.send_keys 'C-g' + tmux.until { |lines| lines[-1].start_with? 'foo' } + end + def retries(times = 3) (times - 1).times do begin @@ -2044,17 +2048,16 @@ class TestBash < TestBase include TestShell include CompletionTest + def shell + :bash + end + def new_shell tmux.prepare tmux.send_keys "FZF_TMUX=1 #{Shell.bash}", :Enter tmux.prepare end - def setup - super - @tmux = Tmux.new :bash - end - def test_dynamic_completion_loader tmux.paste 'touch /tmp/foo; _fzf_completion_loader=1' tmux.paste '_completion_loader() { complete -o default fake; }' @@ -2077,20 +2080,23 @@ class TestZsh < TestBase include TestShell include CompletionTest + def shell + :zsh + end + def new_shell tmux.send_keys "FZF_TMUX=1 #{Shell.zsh}", :Enter tmux.prepare end - - def setup - super - @tmux = Tmux.new :zsh - end end class TestFish < TestBase include TestShell + def shell + :fish + end + def new_shell tmux.send_keys 'env FZF_TMUX=1 fish', :Enter tmux.send_keys 'function fish_prompt; end; clear', :Enter @@ -2102,11 +2108,6 @@ class TestFish < TestBase tmux.send_keys "set -g #{name} '#{val}'", :Enter tmux.prepare end - - def setup - super - @tmux = Tmux.new :fish - end end __END__ -- cgit v1.2.3