Stop polluting FZF_KEY with synthetic events

lastKey was overwritten every time a synthetic event (every(N), Focus,
Result, ...) was processed, so FZF_KEY would briefly show "every(1)"
or empty string instead of the user's actual last keystroke.

Gate the assignment on `< Invalid` so only user-input events update
lastKey, and drop the now-unused every() formatting in KeyName.
This commit is contained in:
Junegunn Choi
2026-05-17 09:29:33 +09:00
parent 6657639578
commit dacf10a3ba
3 changed files with 3 additions and 9 deletions
-4
View File
@@ -330,10 +330,6 @@ func TestParseEveryEvent(t *testing.T) {
} }
} }
// KeyName round-trips with the original duration
if got := (tui.Event{Type: tui.Every, Char: 2000}).KeyName(); got != "every(2)" {
t.Errorf("KeyName: %q != every(2)", got)
}
} }
func TestColorSpec(t *testing.T) { func TestColorSpec(t *testing.T) {
+3 -1
View File
@@ -6478,7 +6478,9 @@ func (t *Terminal) Loop() error {
previousInput := t.input previousInput := t.input
previousCx := t.cx previousCx := t.cx
previousVersion := t.version previousVersion := t.version
t.lastKey = event.KeyName() if event.Type < tui.Invalid {
t.lastKey = event.KeyName()
}
updatePreviewWindow := func(forcePreview bool) { updatePreviewWindow := func(forcePreview bool) {
t.resizeWindows(forcePreview, false) t.resizeWindows(forcePreview, false)
req(reqPrompt, reqList, reqInfo, reqHeader, reqFooter) req(reqPrompt, reqList, reqInfo, reqHeader, reqFooter)
-4
View File
@@ -257,10 +257,6 @@ func (e Event) KeyName() string {
return me.Name() return me.Name()
} }
if e.Type == Every {
return "every(" + strconv.FormatFloat(float64(e.Char)/1000, 'f', -1, 64) + ")"
}
if e.Type >= Invalid { if e.Type >= Invalid {
return "" return ""
} }