Fix query precedence in an action chain (#4326)

When 'search' and any action that modifies the query are in an action
chain, anything that comes later takes precedence.
This commit is contained in:
Junegunn Choi 2025-03-26 15:47:43 +09:00
parent 4a0ab6c926
commit 998c57442b
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 11 additions and 3 deletions

View File

@ -6039,6 +6039,8 @@ func (t *Terminal) Loop() error {
t.input = currentInput t.input = currentInput
t.cx = len(t.input) t.cx = len(t.input)
beof = false beof = false
} else if string(t.input) != string(currentInput) {
t.inputOverride = nil
} }
return true return true
} }
@ -6064,9 +6066,6 @@ func (t *Terminal) Loop() error {
t.truncateQuery() t.truncateQuery()
} }
queryChanged = queryChanged || t.pasting == nil && string(previousInput) != string(t.input) queryChanged = queryChanged || t.pasting == nil && string(previousInput) != string(t.input)
if queryChanged {
t.inputOverride = nil
}
changed = changed || queryChanged changed = changed || queryChanged
if onChanges, prs := t.keymap[tui.Change.AsEvent()]; queryChanged && prs && !doActions(onChanges) { if onChanges, prs := t.keymap[tui.Change.AsEvent()]; queryChanged && prs && !doActions(onChanges) {
continue continue

View File

@ -1881,4 +1881,13 @@ class TestCore < TestInteractive
assert_includes lines, '> 555' assert_includes lines, '> 555'
end end
end end
def test_search_override_query_in_no_input_mode
tmux.send_keys %(seq 1000 | #{FZF} --sync --no-input --bind 'enter:show-input+change-query(555)+hide-input+search(999),space:search(111)+show-input+change-query(777)'), :Enter
tmux.until { |lines| assert_includes lines, '> 1' }
tmux.send_keys :Enter
tmux.until { |lines| assert_includes lines, '> 999' }
tmux.send_keys :Space
tmux.until { |lines| assert_includes lines, '> 777' }
end
end end