Commit Graph
3 Commits
Author SHA1 Message Date
Junegunn Choi 9c667afb73 Wait for a string terminator split across reads
A trailing ESC was read as a lone ESC, so the read loop stopped waiting and
the parser was handed an unterminated sequence, whose payload was typed into
the query. With ESCDELAY=0 nothing covered it.

Reported by Copilot on #4926.
2026-09-27 21:03:07 +09:00
Junegunn Choi 993abd8a80 Drop unrecognized escape sequences instead of typing them
fzf consumed only the part of a sequence it recognized, and the rest was
typed into the query. CTRL-A sent as \e[97;5u became "97;5u". A
BEL-terminated OSC reply also aborted fzf, because the BEL that followed
the typed payload was read as CTRL-G.

Frame CSI by its parameter and final byte ranges, OSC, DCS and APC by
their terminator, then drop the whole sequence when nothing matches it.

- Wait for a string terminator in the read loop, as already done for CSI
- Take the second-chance read only while a sequence is unfinished. After
  a complete one it blocked until the next keystroke
- Leave unterminated sequences alone. ALT-[ and ALT-] arrive that way
- Skip SOS and PM. Nothing sends them, so ALT-X and ALT-^ do not wait
2026-09-27 20:53:13 +09:00
Junegunn Choi d0377ed4dc Wait for rest of escape sequence before parsing (#4901)
CodeQL / Analyze (go) (push) Canceled after 0s
build / build (push) Canceled after 0s
Test fzf on macOS / build (push) Canceled after 0s
Read loop dropped its escDelay retry budget after every successful byte,
so a sequence split across reads reached the parser as a fragment, parsed
as ALT-[ with the remainder left behind as query text.

- fzf queries DECRQM at startup since dab626b, so a terminal answering
  late leaked "?2004;2$y" into the query
- Same split leaked modified keys and mouse sequences: CTRL-UP left "5A",
  SGR mouse left "0;1;1M"
- Bound unchanged, a stall longer than escDelay still falls back to ALT

Fix #4899
2026-08-24 00:40:06 +09:00