From db266643aa7dfcbfb00feb802c235e5af402b50d Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sun, 29 Nov 2026 16:55:39 +0800 Subject: [PATCH] feat(terminal): add an optional Paste on right click (#6825) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- crates/ide-core/src/workflow_settings.rs | 3 ++ docs/en/guide/terminal.mdx | 1 + docs/zh/guide/terminal.mdx | 1 + e2e/terminal-ui.spec.ts | 35 ++++++++++++++++++++++++ src/bindings.ts | 2 ++ src/features/settings/pages/tools.tsx | 1 + src/features/terminal/TerminalView.tsx | 10 +++++++ src/platform/clientSettings.ts | 1 + src/platform/locales/text/zh-TW.json | 1 + src/platform/locales/text/zh.json | 1 + src/platform/workflowSettings.ts | 4 +++ 11 files changed, 60 insertions(+) diff --git a/crates/ide-core/src/workflow_settings.rs b/crates/ide-core/src/workflow_settings.rs index 72710b526..a85017b18 100644 --- a/crates/ide-core/src/workflow_settings.rs +++ b/crates/ide-core/src/workflow_settings.rs @@ -617,6 +617,8 @@ pub struct TerminalSettings { pub mouse_reporting: bool, pub copy_on_selection: bool, pub paste_on_middle_click: bool, + /// Right-click pastes instead of opening the context menu (Ctrl or Shift + right-click still opens it). + pub right_click_paste: bool, pub override_ide_shortcuts: bool, pub shell_integration: bool, pub highlight_hyperlinks: bool, @@ -655,6 +657,7 @@ impl Default for TerminalSettings { mouse_reporting: true, copy_on_selection: false, paste_on_middle_click: true, + right_click_paste: false, override_ide_shortcuts: true, shell_integration: true, highlight_hyperlinks: true, diff --git a/docs/en/guide/terminal.mdx b/docs/en/guide/terminal.mdx index 0c7841982..30f016b5c 100644 --- a/docs/en/guide/terminal.mdx +++ b/docs/en/guide/terminal.mdx @@ -90,6 +90,7 @@ With **Shell integration** on, zsh, bash and fish report the current directory a | **Mouse reporting** | on | Off: programs can't capture the mouse. | | **Copy to clipboard on selection** | off | | | **Paste on middle mouse button click** | on | | +| **Paste on right click** | off | On: right-click pastes; Ctrl or Shift + right-click opens the context menu. | | **Move focus to the Editor with Escape** | off | Otherwise `Esc` goes to the shell. | | **Override IDE shortcuts** | on | See above. | | **Shell integration** | on | | diff --git a/docs/zh/guide/terminal.mdx b/docs/zh/guide/terminal.mdx index 726bdd118..892c6e1f9 100644 --- a/docs/zh/guide/terminal.mdx +++ b/docs/zh/guide/terminal.mdx @@ -90,6 +90,7 @@ OpenIDEA 会按项目记住终端标签页:各自的目录、自定义名称 | **鼠标报告** | 开 | 关闭后程序无法捕获鼠标。 | | **选择时复制到剪贴板** | 关 | | | **点击鼠标中键时粘贴** | 开 | | +| **右键单击时粘贴** | 关 | 开启后右键单击直接粘贴;按住 Ctrl 或 Shift 右键单击仍打开上下文菜单。 | | **按 Escape 将焦点移到编辑器** | 关 | 关闭时 `Esc` 发给 Shell。 | | **覆盖 IDE 快捷键** | 开 | 见上文。 | | **Shell 集成** | 开 | | diff --git a/e2e/terminal-ui.spec.ts b/e2e/terminal-ui.spec.ts index ed47248d3..cced17b61 100644 --- a/e2e/terminal-ui.spec.ts +++ b/e2e/terminal-ui.spec.ts @@ -118,6 +118,41 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 }, }); } +test("Paste on right click pastes on a plain right-click and keeps the menu on Shift+right-click", async ({ + workbench: page, +}) => { + const terminal = page.getByRole("region", { name: "Terminal", exact: true }); + await page.evaluate(async () => { + const layout = await import("/src/workbench/toolwindows/store.ts" as string); + layout.showToolWindow("terminal", true); + }); + const output = terminal.getByRole("tabpanel").locator(".xterm"); + await expect(terminal.locator(".xterm-helper-textarea")).toBeFocused(); + await page.evaluate(async () => { + const { useProject } = await import("/src/platform/project.ts" as string); + const settings = useProject.getState().settings ?? {}; + useProject.setState({ + settings: { ...settings, terminal: { ...settings.terminal, rightClickPaste: true } }, + }); + const { activeSession } = await import("/src/features/terminal/store.ts" as string); + const session = activeSession(); + const w = window as unknown as { __pastes: number }; + w.__pastes = 0; + session.pasteClipboard = () => { + w.__pastes += 1; + return Promise.resolve(); + }; + }); + const menu = page.getByRole("menu", { name: "Context menu" }); + await output.click({ button: "right", position: { x: 25, y: 50 } }); + await expect.poll(() => page.evaluate(() => (window as unknown as { __pastes: number }).__pastes)).toBe(1); + await expect(menu).toBeHidden(); + await expect(terminal.locator(".xterm-helper-textarea")).toBeFocused(); + await output.click({ button: "right", modifiers: ["Shift"], position: { x: 25, y: 50 } }); + await expect(menu.getByRole("menuitem", { name: /^Paste/ })).toBeVisible(); + expect(await page.evaluate(() => (window as unknown as { __pastes: number }).__pastes)).toBe(1); +}); + test("wide terminal search leaves the grid in place and avoids covering the active match", async ({ workbench: page, }) => { diff --git a/src/bindings.ts b/src/bindings.ts index 1d5e9877c..817311f4f 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -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, diff --git a/src/features/settings/pages/tools.tsx b/src/features/settings/pages/tools.tsx index ee9967c5d..8181f3113 100644 --- a/src/features/settings/pages/tools.tsx +++ b/src/features/settings/pages/tools.tsx @@ -254,6 +254,7 @@ function TerminalOptions() { +