Files
zellij/zellij-client
ZrjaKandAram Drevekenin 1d1d5c1101 fix(input): realign raw-byte buffer with the keyboard parser to stop stale bytes eating keystrokes (#5446)
* fix(input): realign raw-byte buffer with the keyboard parser to stop stale bytes eating keystrokes

After a paste (e.g. via a clipboard manager like maccy), zellij's
current_buffer can hold up to a few stale bytes that termwiz's
InputParser has already consumed into events. Those stale bytes are then
attached to the raw payload of subsequent KeyEvent messages, desyncing
each keystroke from the bytes that produced it: keys go missing, come
out garbled, or drop into vi command mode.

The root cause is that parse_with_consumed reports consumption relative
to its internal self.buf, while stdin_handler drains a separately
accumulated current_buffer. The two can drift apart whenever a read
leaves a partial sequence that the parser holds under maybe_more.

Reconcile the two after every parse: trim current_buffer to the
parser's buffered length, so no byte the parser has already decoded is
ever forwarded with a later key event. Add InputParser::buffered_len to
the vendored termwiz for that purpose.

* fix: remove parsed bytes from front rather than back

* rustfmt

---------

Co-authored-by: Aram Drevekenin <[email protected]>
2026-08-10 14:17:09 +02:00
..
2026-08-05 15:32:53 +02:00
2026-07-30 10:43:00 +02:00