Skip to content

fix(renderer): update selection focus on mouseUp for multiplexer compatibility#935

Open
INONONO66 wants to merge 4 commits into
anomalyco:mainfrom
INONONO66:fix/selection-mouseup-multiplexer
Open

fix(renderer): update selection focus on mouseUp for multiplexer compatibility#935
INONONO66 wants to merge 4 commits into
anomalyco:mainfrom
INONONO66:fix/selection-mouseup-multiplexer

Conversation

@INONONO66

Copy link
Copy Markdown

Summary

Terminal multiplexers (e.g. cmux) may not forward mouse drag events to child processes. Without drag events, startSelection sets both anchor and focus to the mouseDown position, but updateSelection is never called during the drag. When mouseUp fires, finishSelection runs with the focus still at the anchor — resulting in a single-character selection.

Fix

Call updateSelection with the mouseUp coordinates before finishSelection, so the selection always spans from mouseDown to mouseUp at minimum.

In normal terminals (where drag events are forwarded), the last drag and mouseUp share the same coordinates, making this a no-op.

Reproduction

  1. Run an OpenTUI app inside a terminal multiplexer that doesn't forward drag events (e.g. cmux)
  2. Drag-select text
  3. Only the first character is selected/copied

Test

Added "selection mouseUp without drag events updates focus to release coordinates" to renderer.mouse.test.ts — simulates the multiplexer scenario by calling pressDown then release with no intermediate moveTo.

…atibility

Terminal multiplexers (e.g. cmux) may not forward mouse drag events to
child processes. Without drag events, startSelection sets anchor and
focus to the same mouseDown position. When mouseUp fires,
finishSelection is called without the focus ever being updated,
resulting in a single-character selection.

Call updateSelection with the mouseUp coordinates before finishSelection
so the selection always spans from mouseDown to mouseUp at minimum.
In normal terminals this is a no-op since the last drag and mouseUp
share the same coordinates.
@simonklee

Copy link
Copy Markdown
Member

/fmt

@simonklee

Copy link
Copy Markdown
Member

/review

Comment thread packages/core/src/tests/renderer.mouse.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants