Skip to content
Myr

An '--expect' key should execute actions bound to the key

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

Fix #3810

authored by Junegunn Choi · committed by Junegunn Choi · parent 552158f · Browse files · 2 files+19 added−8 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+19 added−8 removed

  • tests:+7 added−0 removed
  • other:+12 added−8 removed

2 files+19 added−8 removed

modified:src/terminal.go+12 added-8 removed
3557 unmodified lines
3558 }3559 scrollPreviewBy := func(amount int) {3560 scrollPreviewTo(t.previewer.offset + amount)3561 }3562 for key, ret := range t.expect {3563 if keyMatch(key, event) {3564 t.pressed = ret3565 t.reqBox.Set(reqClose, nil)3566 t.mutex.Unlock()3567 return nil3568 }3569 }35623563 actionsFor := func(eventType tui.EventType) []*action {3564 return t.keymap[eventType.AsEvent()]3565 }
798 unmodified lines
4364 }4365 return true4366 }43674368 for key, ret := range t.expect {4369 if keyMatch(key, event) {4370 t.pressed = ret4371 if actions, found := t.keymap[key]; found {4372 doActions(actions)4373 }4374 t.reqBox.Set(reqClose, nil)4375 t.mutex.Unlock()4376 return nil4377 }4378 }43794380 if t.jumping == jumpDisabled || len(actions) > 0 {4381 // Break out of jump mode if any action is submitted to the server4382 if t.jumping != jumpDisabled {4383 t.jumping = jumpDisabled
215 unmodified lines
modified:test/test_go.rb+7 added
578 unmodified lines
579 end580 test.call('@', '@')581 end582583 def test_expect_with_bound_actions584 tmux.send_keys "seq 1 100 | #{fzf('--query 1 --print-query --expect z --bind z:up+up')}", :Enter585 tmux.until { |lines| assert_equal 20, lines.match_count }586 tmux.send_keys('z')587 assert_equal %w[1 z 11], readonce.lines(chomp: true)588 end589590 def test_expect_print_query591 tmux.send_keys "seq 1 100 | #{fzf('--expect=alt-z', :print_query)}", :Enter592 tmux.until { |lines| assert_equal ' 100/100', lines[-2] }593 tmux.send_keys '55'
3215 unmodified lines