Skip to content

Only activate links on primary mouse button - #6194

Open
dmke wants to merge 1 commit into
xtermjs:masterfrom
dmke:fix/link-activate-primary-button
Open

dmke wants to merge 1 commit into
xtermjs:masterfrom
dmke:fix/link-activate-primary-button

Conversation

@dmke

@dmke dmke commented Sep 28, 2026

Copy link
Copy Markdown

Fixes #4052

Problem

Linkifier activates a link on mouseup of any mouse button. Embedders whose activate handler calls event.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 _handleMouseUp unless event.button === 0. Middle and right clicks keep their native meaning (paste, context menu) and no longer trigger link activation.

Tests

Linkifier.test.ts gets a test that sends mousedown/mouseup for buttons 0, 1 and 2 and checks that only button 0 activates the link. It
fails without the change. tsc, oxlint and eslint


Note

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

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
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.

Inserting X selections requires precise mouse positioning

1 participant