Skip to content

Commit 297e3d4

Browse files
yogeshwaran-cclaude
andcommitted
terminal: fix unreliable middle-click paste on Linux
On Linux the middle-click paste in the terminal was unreliable when the click occurred over a word because xterm.js intercepts the mouse event to select the word before the browser can perform the primary-selection paste. Instead of relying on Chromium's primary-selection paste, this change explicitly pastes the primary selection clipboard when middleClickBehavior is 'default' on Linux, matching the behavior users expect and making the paste reliable regardless of cursor position. Fixes microsoft#272927 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent f4e6a58 commit 297e3d4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/vs/workbench/contrib/terminalContrib/clipboard/browser/terminal.clipboard.contribution.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ export class TerminalClipboardContribution extends Disposable implements ITermin
120120
this.paste();
121121
return { handled: true };
122122
}
123+
// On Linux with 'default' middle click behavior, explicitly paste the
124+
// primary selection clipboard. Relying on the browser to handle the
125+
// middle-click paste is unreliable when the click occurs over a word
126+
// because xterm.js intercepts the mouse event to select the word before
127+
// the browser can perform the paste.
128+
if (isLinux && this._terminalConfigurationService.config.middleClickBehavior === 'default') {
129+
this.pasteSelection();
130+
return { handled: true };
131+
}
123132
break;
124133
}
125134
case 2: { // Right click

0 commit comments

Comments
 (0)