mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 04:55:58 +03:00
[PR #727] [CLOSED] fix(stdin-buffer): handle split escape sequences #1522
Labels
No labels
bug
core
documentation
feature
good first issue
help wanted
pull-request
question
react
solid
tmux
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/opentui#1522
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/anomalyco/opentui/pull/727
Author: @yukukotani
Created: 2/22/2026
Status: ❌ Closed
Base:
main← Head:delay-flash-esc📝 Commits (2)
48d195afix(stdin-buffer): delay lone ESC flush to reassemble split focus sequences7519ea3fix(stdin-buffer): extend flush delay to all incomplete escape sequences📊 Changes
2 files changed (+176 additions, -6 deletions)
View changed files
📝
packages/core/src/lib/stdin-buffer.test.ts(+162 -5)📝
packages/core/src/lib/stdin-buffer.ts(+14 -1)📄 Description
Summary
ESC[Iarriving asESCthen[I, orESC[thenI) reassemble naturallyisCompleteSequence()logic — no new fields or state management neededProblem
Ghostty (and potentially other terminals) can deliver focus event sequences (
ESC[I/ESC[O) split across multiple chunks. TheStdinBuffertimeout (5ms) would flush the incomplete sequence before the rest arrived, causing fragments like[Ito leak into the input as literal text.Solution
When the timeout fires and the buffer contains an incomplete escape sequence (as determined by the existing
isCompleteSequence()), extend the timeout once (50ms) to give the next chunk time to arrive and reassemble through the normal CSI completion logic.Changes
packages/core/src/lib/stdin-buffer.ts— 1-line condition change in the timeout handler:isCompleteSequence(this.buffer) === "incomplete"triggers a single timeout extensionpackages/core/src/lib/stdin-buffer.test.ts— Added 14 test cases for split focus sequences; updated 2 existing tests for new timeout behavior; added buffer cleanup inbeforeEachTesting
All existing tests pass:
stdin-buffer.test.ts(123 tests)renderer.input.test.ts(60 tests)renderer.focus-restore.test.ts(9 tests)parse.keypress.test.ts(41 tests)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.