mirror of
https://github.com/anomalyco/opentui.git
synced 2026-04-25 13:06:00 +03:00
[PR #461] fix: Handle combined mouse event and paste sequences in stdin buffer #553
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#553
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/461
Author: @d3vr
Created: 12/31/2025
Status: 🔄 Open
Base:
main← Head:main📝 Commits (1)
c859dfefix: Handle combined mouse event and paste sequences in stdin buffer📊 Changes
4 files changed (+197 additions, -27 deletions)
View changed files
➕
packages/core/src/lib/parse.mouse.test.ts(+142 -0)📝
packages/core/src/lib/parse.mouse.ts(+40 -15)📝
packages/core/src/renderer.ts(+11 -2)📝
packages/core/src/testing/integration.test.ts(+4 -10)📄 Description
Drag-and-drop file paths from a file manager into terminals using OpenTUI-based applications (like OpenCode) was not working in Alacritty, while it worked correctly in Ghostty/Kitty/others.
Root Cause Analysis
When a file is dragged and dropped into a terminal, the terminal sends the file path as a bracketed paste sequence (
\x1b[200~...\x1b[201~). However, different terminals emit these sequences differently:Alacritty's combined sequence:
The bug occurred because:
stdinListener()calledhandleMouseData(data)with the full bufferMouseParser.parseMouseEvent()found the mouse event using regexmatch()(not anchored)handleMouseData()returnedtrue, signaling the entire buffer was handledSolution
Added a new method
parseMouseEventWithConsumed()toMouseParserthat returns both the parsed event and the number of bytes consumed. This allows the caller to process any remaining data in the buffer.Key changes:
parse.mouse.ts:MouseParseResulttype:{ event: RawMouseEvent, consumed: number }parseMouseEventWithConsumed()method with^-anchored regexparseMouseEvent()to call the new method (maintains backward compatibility, since the method was exported, I erred on the safe side).renderer.ts:handleMouseData()to useparseMouseEventWithConsumed()_stdinBuffer.process()Flow after fix:
Testing
parse.mouse.test.ts(11 tests)parseAllEventshelper in integration tests to use the new methodRelated
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.