mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[PR #757] [CLOSED] fix: forward unconsumed data after mouse sequence parsing #1541
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#1541
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/757
Author: @amosbird
Created: 3/1/2026
Status: ❌ Closed
Base:
main← Head:fix/mouse-sequence-split-data-loss📝 Commits (1)
98813cafix: forward unconsumed data after mouse sequence parsing📊 Changes
4 files changed (+56 additions, -21 deletions)
View changed files
📝
packages/core/src/lib/parse.mouse.test.ts(+42 -10)📝
packages/core/src/lib/parse.mouse.ts(+2 -2)📝
packages/core/src/renderer.ts(+11 -8)📝
packages/core/src/testing/integration.test.ts(+1 -1)📄 Description
Summary
parseAllMouseEventsnow returns aconsumedbyte offset alongside parsed events, telling the caller exactly how many bytes were successfully parsedhandleMouseDatain the renderer forwards any unconsumed trailing data to_stdinBuffer.process()instead of silently dropping itProblem
When a stdin chunk contains complete mouse escape sequences followed by a partial one (e.g.
\x1b[<0;31;16M\x1b[<0;),parseAllMouseEventsparses the complete event but the partial trailing bytes are silently dropped. When the next stdin chunk arrives with the remainder (31;16M), it can't be parsed as a mouse event (no\x1b[prefix), so it falls through to keyboard input handling — causing characters like31M;to appear in the input box.This is most commonly triggered by rapid mouse movement during terminal focus switches.
Changes
parse.mouse.ts: ChangedparseAllMouseEventsreturn type fromRawMouseEvent[]to{ events: RawMouseEvent[]; consumed: number }.renderer.ts:handleMouseDatanow checks ifconsumed < data.lengthand forwards the unconsumed remainder to_stdinBuffer.process(), which correctly handles partial CSI sequences with its existing buffering/timeout logic.parse.mouse.test.ts: Updated all call sites for new return type. Added 5 new tests coveringconsumedoffset behavior (full consumption, trailing non-mouse data, partial SGR sequences, empty/non-mouse input).integration.test.ts: Updated helper to access.eventsfrom the new return type.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.