Repository navigation
Conversation
Links were activated on mouseup of any button. Embedders that call preventDefault() in their activate handler (like VS Code) thereby blocked the browser's default action for other buttons, most notably middle click paste of the selection clipboard on Linux. Fixes xtermjs#4052
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.
Fixes #4052
Problem
Linkifieractivates a link onmouseupof any mouse button. Embedders whoseactivatehandler callsevent.preventDefault()(VS Code does) end up cancelling the browser's default action for the other buttons too. The most visible case: Chromium's middle click paste of the selection clipboard on Linux silently stops working whenever the pointer is over a link.In VS Code every word in the terminal is a link, so middle click paste only works on empty terminal space (microsoft/vscode#157233).
Fix
Return early in
_handleMouseUpunlessevent.button === 0. Middle and right clicks keep their native meaning (paste, context menu) and no longer trigger link activation.Tests
Linkifier.test.tsgets a test that sends mousedown/mouseup for buttons 0, 1 and 2 and checks that only button 0 activates the link. Itfails without the change.
tsc,oxlintandeslintNote
This PR was prepared with the assistance of an AI coding agent (Claude Code), including the root cause analysis, the fix and the test. I've reviewed the change and tested it locally