Skip to content
Myr

feat(zsh): Handle multi-line history selection (#4595)

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

authored by LangLangBart · committed by GitHub · parent af2a81d · Browse files · 2 files+111 added−6 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+111 added−6 removed

  • tests:+78 added−0 removed
  • other:+33 added−6 removed

2 files+111 added−6 removed

modified:shell/key-bindings.zsh+33 added-6 removed
modified:test/test_shell_integration.rb+78 added
460 unmodified lines
461 tmux.until { |lines| assert_equal "#{command} FZFFOOBAR", lines[-1] }462 tmux.send_keys 'C-c'463 end464 end465466 # Helper function to run test with Perl and again with Awk467 def self.test_perl_and_awk(name, &block)468 define_method("test_#{name}") do469 instance_eval(&block)470 end471472 define_method("test_#{name}_awk") do473 tmux.send_keys "unset 'commands[perl]'", :Enter474 tmux.prepare475 # Verify perl is actually unset (0 = not found)476 tmux.send_keys 'echo ${+commands[perl]}', :Enter477 tmux.until { |lines| assert_equal '0', lines[-1] }478 tmux.prepare479 instance_eval(&block)480 end481 end482483 def prepare_ctrl_r_test484 tmux.send_keys ':', :Enter485 tmux.send_keys 'echo match-collision', :Enter486 tmux.prepare487 tmux.send_keys 'echo "line 1', :Enter, '2 line 2"', :Enter488 tmux.prepare489 tmux.send_keys 'echo "foo', :Enter, 'bar"', :Enter490 tmux.prepare491 tmux.send_keys 'echo "bar', :Enter, 'foo"', :Enter492 tmux.prepare493 tmux.send_keys 'echo "trailing_space "', :Enter494 tmux.prepare495 tmux.send_keys 'cat <<EOF | wc -c', :Enter, 'qux thud', :Enter, 'EOF', :Enter496 tmux.prepare497 tmux.send_keys 'C-l', 'C-r'498 end499500 test_perl_and_awk 'ctrl_r_accept_or_print_query' do501 set_var('FZF_CTRL_R_OPTS', '--bind enter:accept-or-print-query')502 prepare_ctrl_r_test503 tmux.until { |lines| assert_operator lines.match_count, :>, 0 }504 tmux.send_keys '1 foobar'505 tmux.until { |lines| assert_equal 0, lines.match_count }506 tmux.send_keys :Enter507 tmux.until { |lines| assert_equal '1 foobar', lines[-1] }508 end509510 test_perl_and_awk 'ctrl_r_multiline_index_collision' do511 # Leading number in multi-line history content is not confused with index512 prepare_ctrl_r_test513 tmux.send_keys "'line 1"514 tmux.until { |lines| assert_equal 1, lines.match_count }515 tmux.send_keys :Enter516 tmux.until do |lines|517 assert_equal ['echo "line 1', '2 line 2"'], lines[-2..]518 end519 end520521 test_perl_and_awk 'ctrl_r_multi_selection' do522 prepare_ctrl_r_test523 tmux.until { |lines| assert_operator lines.match_count, :>, 0 }524 tmux.send_keys :BTab, :BTab, :BTab525 tmux.until { |lines| assert_includes lines[-2], '(3)' }526 tmux.send_keys :Enter527 tmux.until do |lines|528 assert_equal ['cat <<EOF | wc -c', 'qux thud', 'EOF', 'echo "trailing_space "', 'echo "bar', 'foo"'], lines[-6..]529 end530 end531532 test_perl_and_awk 'ctrl_r_no_multi_selection' do533 set_var('FZF_CTRL_R_OPTS', '--no-multi')534 prepare_ctrl_r_test535 tmux.until { |lines| assert_operator lines.match_count, :>, 0 }536 tmux.send_keys :BTab, :BTab, :BTab537 tmux.until { |lines| refute_includes lines[-2], '(3)' }538 tmux.send_keys :Enter539 tmux.until do |lines|540 assert_equal ['cat <<EOF | wc -c', 'qux thud', 'EOF'], lines[-3..]541 end542 end543end544545class TestFish < TestBase546 include TestShell
49 unmodified lines