diff --git a/src/terminal.go b/src/terminal.go index 8feb2799..f25cd2f3 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -2719,11 +2719,6 @@ func (t *Terminal) Loop() { } } - var onFocus []*action - if actions, prs := t.keymap[tui.Focus.AsEvent()]; prs { - onFocus = actions - } - go func() { var focusedIndex int32 = minItem.Index() var version int64 = -1 @@ -2764,7 +2759,7 @@ func (t *Terminal) Loop() { t.track = trackDisabled t.printInfo() } - if onFocus != nil && focusChanged { + if onFocus, prs := t.keymap[tui.Focus.AsEvent()]; prs && focusChanged { t.serverChan <- onFocus } if focusChanged || version != t.version { diff --git a/test/test_go.rb b/test/test_go.rb index 3a768744..1f4245ab 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -2628,12 +2628,16 @@ class TestGoFZF < TestBase end def test_focus_event - tmux.send_keys 'seq 100 | fzf --bind "focus:transform-prompt(echo [[{}]])"', :Enter + tmux.send_keys 'seq 100 | fzf --bind "focus:transform-prompt(echo [[{}]]),?:unbind(focus)"', :Enter tmux.until { |lines| assert_includes(lines[-1], '[[1]]') } tmux.send_keys :Up tmux.until { |lines| assert_includes(lines[-1], '[[2]]') } tmux.send_keys :X tmux.until { |lines| assert_includes(lines[-1], '[[]]') } + tmux.send_keys '?' + tmux.send_keys :BSpace + tmux.until { |lines| assert_equal 100, lines.match_count } + tmux.until { |lines| refute_includes(lines[-1], '[[1]]') } end def test_labels_center