mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[GH-ISSUE #644] stdin-buffer incorrectly splits double-escape sequences (Option+Arrow on macOS) #173
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#173
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?
Originally created by @pedropombeiro on GitHub (Feb 7, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/644
Description
When using Option+Arrow keys on macOS terminals (iTerm2, etc.), the double-escape sequence
\x1b\x1b[D(Option+Left) is incorrectly split by the stdin buffer, causing[Dto be printed as literal text instead of being recognized as a key event.Environment
\x1b\x1b[Dfor Option+Left (verified withcat -vshowing^[^[[D)Root Cause
In
packages/core/src/lib/stdin-buffer.ts, theisCompleteSequencefunction doesn't handle the case whereafterEscstarts with another ESC character (the double-escape pattern for meta/option modified keys).Current flow for input
\x1b\x1b[D:\x1b)afterEsc=\x1b[DafterEsc.startsWith("[")→ false (it starts with\x1b)afterEsc.startsWith("]")→ falseafterEsc.startsWith("O")→ falseafterEsc.length === 1→ false (length is 3)return "complete"on line 74This causes
extractCompleteSequencesto emit:\x1b\x1bas one "complete" sequence[Das literal text (the bug!)Expected Behavior
The sequence
\x1b\x1b[Dshould be kept together and recognized as Option/Meta + Left Arrow, as the parser inparse.keypress.tsalready has logic to handle this (lines 331-337).Proposed Fix
Add handling in
isCompleteSequencefor whenafterEscstarts with ESC:Related Issues