fix(renderer): update selection focus on mouseUp for multiplexer compatibility#935
Open
INONONO66 wants to merge 3 commits intoanomalyco:mainfrom
Open
fix(renderer): update selection focus on mouseUp for multiplexer compatibility#935INONONO66 wants to merge 3 commits intoanomalyco:mainfrom
INONONO66 wants to merge 3 commits intoanomalyco:mainfrom
Conversation
…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.
Member
|
/fmt |
Member
|
/review |
| import type { MouseEvent } from "../renderer.js" | ||
| import type { RenderContext } from "../types.js" | ||
| import type { Selection } from "../lib/selection.js" | ||
| import { beforeEach, describe, expect, test } from "bun:test"; |
There was a problem hiding this comment.
The test file has been reformatted with semicolons added throughout. According to AGENTS.md, the project uses oxfmt (semi: false). The main branch has no semicolons in this file. This looks like an unintended formatter change - consider reverting the semicolon additions to keep the file consistent with the rest of the codebase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Terminal multiplexers (e.g. cmux) may not forward mouse drag events to child processes. Without drag events,
startSelectionsets both anchor and focus to the mouseDown position, butupdateSelectionis never called during the drag. When mouseUp fires,finishSelectionruns with the focus still at the anchor — resulting in a single-character selection.Fix
Call
updateSelectionwith the mouseUp coordinates beforefinishSelection, 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
Test
Added
"selection mouseUp without drag events updates focus to release coordinates"torenderer.mouse.test.ts— simulates the multiplexer scenario by callingpressDownthenreleasewith no intermediatemoveTo.