feat(terminal): add an optional Paste on right click (#6825)

Settings › Tools › Terminal gains Paste on right click (terminal.rightClickPaste, off by default). When on, a plain right-click in a terminal pane pastes the clipboard through the same path as Paste and middle-click paste, so bracketed paste and multiline handling are unchanged; Ctrl or Shift + right-click still opens the context menu, and focus stays in the pane.

Fixes #6634
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-29 16:55:39 +08:00
1 джерело 4812d28614
коміт db266643aa
11 files changed
+60

No files matched your search

+2
Переглянути файл
@@ -15104,6 +15104,8 @@ export type TerminalSettings = {
mouseReporting?: boolean,
copyOnSelection?: boolean,
pasteOnMiddleClick?: boolean,
/** Right-click pastes instead of opening the context menu (Ctrl or Shift + right-click still opens it). */
rightClickPaste?: boolean,
overrideIdeShortcuts?: boolean,
shellIntegration?: boolean,
highlightHyperlinks?: boolean,
+1
Переглянути файл
@@ -254,6 +254,7 @@ function TerminalOptions() {
<BoundToggle k="terminal.mouseReporting" label="Mouse reporting" />
<BoundToggle k="terminal.copyOnSelection" label="Copy to clipboard on selection" />
<BoundToggle k="terminal.pasteOnMiddleClick" label="Paste on middle mouse button click" />
<BoundToggle k="terminal.rightClickPaste" label="Paste on right click" />
<BoundToggle
k="terminal.escapeToEditor"
label="Move focus to the Editor with Escape"
+10
Переглянути файл
@@ -7,6 +7,7 @@ import { ToolWindowHeader, useOwnToolWindowHeader } from "@/workbench/toolwindow
import { usePlatform } from "@/platform/platformInfo";
import { commands, isTauri } from "@/platform/ipc";
import { useTx } from "@/platform/i18n";
import { workflowSettings } from "@/platform/workflowSettings";
import {
Badge,
dropZoneAt,
@@ -102,6 +103,10 @@ function paneMenu(e: MouseEvent, key: string) {
// Right-clicking focuses the terminal, like IDEA; otherwise the menu closing
// restores focus to whatever was focused before it, often the editor.
session.focus();
if (rightClickPastes(e, workflowSettings().terminal.rightClickPaste)) {
void session.pasteClipboard();
return;
}
const exited = session.state.status === "exited" || session.state.status === "error";
const mac = usePlatform.getState().os === "macos";
const items: MenuItem[] = [
@@ -141,6 +146,11 @@ function paneMenu(e: MouseEvent, key: string) {
showContextMenu(e, items);
}
/** With Paste on right click on, a plain right-click pastes; Ctrl or Shift + right-click still opens the menu. */
export function rightClickPastes(e: { ctrlKey: boolean; shiftKey: boolean }, enabled: boolean): boolean {
return enabled && !e.ctrlKey && !e.shiftKey;
}
/** The groups of a split window whose headers show its title and its buttons. */
interface Corners {
title: string;
+1
Переглянути файл
@@ -64,6 +64,7 @@ export const CLIENT_SETTINGS_KEYS = [
"terminal.mouseReporting",
"terminal.copyOnSelection",
"terminal.pasteOnMiddleClick",
"terminal.rightClickPaste",
"terminal.overrideIdeShortcuts",
"terminal.highlightHyperlinks",
"terminal.runCommandsUsingIde",
+1
Переглянути файл
@@ -2220,6 +2220,7 @@
"Password:": "密碼:",
"Password already stored": "已儲存密碼",
"Paste": "貼上",
"Paste on right click": "按右鍵時貼上",
"Paste on middle mouse button click": "點選滑鼠中鍵時貼上",
"Patch copied to the clipboard": "補丁已複製到剪貼簿",
"Patch destination": "補丁目標",
+1
Переглянути файл
@@ -2794,6 +2794,7 @@
"Password:": "密码:",
"Password already stored": "已存储密码",
"Paste": "粘贴",
"Paste on right click": "右键单击时粘贴",
"Paste on middle mouse button click": "点击鼠标中键时粘贴",
"Patch copied to the clipboard": "补丁已复制到剪贴板",
"Patch destination": "补丁目标",
+4
Переглянути файл
@@ -205,6 +205,8 @@ export interface TerminalSettingsValid {
mouseReporting: boolean;
copyOnSelection: boolean;
pasteOnMiddleClick: boolean;
/** Right-click pastes instead of opening the context menu (Ctrl or Shift + right-click still opens it). */
rightClickPaste: boolean;
overrideIdeShortcuts: boolean;
shellIntegration: boolean;
highlightHyperlinks: boolean;
@@ -441,6 +443,7 @@ export const DEFAULT_WORKFLOW: WorkflowSettings = {
mouseReporting: true,
copyOnSelection: false,
pasteOnMiddleClick: true,
rightClickPaste: false,
overrideIdeShortcuts: true,
shellIntegration: true,
highlightHyperlinks: true,
@@ -686,6 +689,7 @@ export function validateTerminal(raw: unknown): TerminalSettingsValid {
mouseReporting: bool(v.mouseReporting, d.mouseReporting),
copyOnSelection: bool(v.copyOnSelection, d.copyOnSelection),
pasteOnMiddleClick: bool(v.pasteOnMiddleClick, d.pasteOnMiddleClick),
rightClickPaste: bool(v.rightClickPaste, d.rightClickPaste),
overrideIdeShortcuts: bool(v.overrideIdeShortcuts, d.overrideIdeShortcuts),
shellIntegration: bool(v.shellIntegration, d.shellIntegration),
highlightHyperlinks: bool(v.highlightHyperlinks, d.highlightHyperlinks),