Repository navigation
fix(input): wait for an ST split across reads - #201
Open
jtackaberry wants to merge 1 commit into
Open
jtackaberry wants to merge 1 commit into
jtackaberry wants to merge 1 commit into
Conversation
jtackaberry
force-pushed
the
fix/osc5522
branch
from
October 15, 2026 00:07
2010563 to
2644c68
Compare
A read that ended between the ESC and the backslash of an OSC or APC terminator made the decoder cancel the sequence, dropping it and reporting the backslash as a key. Long replies cross read boundaries constantly (kitty's OSC 5522 clipboard data arrives in thousands of 5 KiB packets), so the sequence is incomplete, not cancelled. The reader now waits for the rest, and only treats it as cancelled if the escape timeout passes first.
jtackaberry
force-pushed
the
fix/osc5522
branch
from
November 10, 2026 01:46
2644c68 to
f638319
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #200.
If a read ends between the
ESCand the\of an OSC or APC terminator,parseOscandparseStTerminatedtreat theESCas cancelling the sequence. The sequence gets dropped, and the\comes through as a key.An
ESCat the very end of the buffer doesn't tell you anything yet, since the next byte decides it. So both parsers now return a new unexportedincompleteEventthere, andscanEventswaits for more input, like it does for any other partial sequence:\arrives, the sequence completes as usual.ESC, which is why the existingignored osccase inTestReadInputstill passes unchanged.Inside a bracketed paste, the same wait applies.
Testing
TestReadInputSplitTerminatorsplits an OSC 5522 packet and an APC sequence just before the final backslash, with anaafter each:\key followed bya.a. The full suite passes too, including with-race.With the programs from the issue:
uv.UnknownOscEventinstead of a\key.kittyread: it no longer finds a stray backslash, however many rounds it runs.Not included
DCS has a related problem. A DCS reply split at the same point comes out without its closing backslash, followed by a separate
\key, both before and after this change.parseDcshandles the terminator differently, so I've left it for a separate change. Happy to add it here if you'd rather.CONTRIBUTING.md.AI Disclosure
AI (Opus 5.5) was used to assist the creation of this PR.