mirror of
https://github.com/junegunn/fzf.git
synced 2026-06-19 07:32:29 +08:00
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:
@@ -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) {
|
||||
|
||||
+3
-1
@@ -6478,7 +6478,9 @@ func (t *Terminal) Loop() error {
|
||||
previousInput := t.input
|
||||
previousCx := t.cx
|
||||
previousVersion := t.version
|
||||
t.lastKey = event.KeyName()
|
||||
if event.Type < tui.Invalid {
|
||||
t.lastKey = event.KeyName()
|
||||
}
|
||||
updatePreviewWindow := func(forcePreview bool) {
|
||||
t.resizeWindows(forcePreview, false)
|
||||
req(reqPrompt, reqList, reqInfo, reqHeader, reqFooter)
|
||||
|
||||
@@ -257,10 +257,6 @@ func (e Event) KeyName() string {
|
||||
return me.Name()
|
||||
}
|
||||
|
||||
if e.Type == Every {
|
||||
return "every(" + strconv.FormatFloat(float64(e.Char)/1000, 'f', -1, 64) + ")"
|
||||
}
|
||||
|
||||
if e.Type >= Invalid {
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user