дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
e3f8902de1 |
No files matched your search
@@ -616,6 +616,8 @@ pub struct TerminalSettings {
|
||||
pub close_on_exit: bool,
|
||||
pub mouse_reporting: bool,
|
||||
pub copy_on_selection: bool,
|
||||
/// Programs may set the clipboard with OSC 52 (tmux, Neovim, TUIs over SSH); never read it.
|
||||
pub osc52_clipboard: 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,
|
||||
@@ -656,6 +658,7 @@ impl Default for TerminalSettings {
|
||||
close_on_exit: true,
|
||||
mouse_reporting: true,
|
||||
copy_on_selection: false,
|
||||
osc52_clipboard: true,
|
||||
paste_on_middle_click: true,
|
||||
right_click_paste: false,
|
||||
override_ide_shortcuts: true,
|
||||
|
||||
@@ -79,26 +79,27 @@ With **Shell integration** on, zsh, bash and fish report the current directory a
|
||||
|
||||
**Settings › Tools › Terminal**:
|
||||
|
||||
| Setting | Default | Notes |
|
||||
| ---------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| **Start directory** | Project root | Relative paths resolve against the project root. **Open in Terminal** still opens the chosen folder. Project setting. |
|
||||
| **Environment variables** | none | Added to new sessions. Project setting. |
|
||||
| **Shell path** | login shell | A command line, e.g. `/bin/zsh --login`. **Installed Shells** lists what was found. |
|
||||
| **Default Tab name** | `Local` | |
|
||||
| **Audible bell** | on | |
|
||||
| **Close session when it ends** | on | |
|
||||
| **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 | |
|
||||
| **Highlight hyperlinks** | on | |
|
||||
| **Use Option as Meta key** | off | macOS only. |
|
||||
| **Cursor shape** | Block | Block, Underline or Vertical. |
|
||||
| **Blinking cursor** | on | |
|
||||
| **Use editor font** | on | Off: set **Font**, **Size** (6–72), **Line height**, **Fallback font** and **Column width**. |
|
||||
| Setting | Default | Notes |
|
||||
| ----------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **Start directory** | Project root | Relative paths resolve against the project root. **Open in Terminal** still opens the chosen folder. Project setting. |
|
||||
| **Environment variables** | none | Added to new sessions. Project setting. |
|
||||
| **Shell path** | login shell | A command line, e.g. `/bin/zsh --login`. **Installed Shells** lists what was found. |
|
||||
| **Default Tab name** | `Local` | |
|
||||
| **Audible bell** | on | |
|
||||
| **Close session when it ends** | on | |
|
||||
| **Mouse reporting** | on | Off: programs can't capture the mouse. |
|
||||
| **Copy to clipboard on selection** | off | |
|
||||
| **Let programs copy to the clipboard (OSC 52)** | on | tmux (`set-clipboard on`), Neovim and other programs set the clipboard, also over SSH. They can't read it; payloads over 1 MiB are ignored. |
|
||||
| **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 | |
|
||||
| **Highlight hyperlinks** | on | |
|
||||
| **Use Option as Meta key** | off | macOS only. |
|
||||
| **Cursor shape** | Block | Block, Underline or Vertical. |
|
||||
| **Blinking cursor** | on | |
|
||||
| **Use editor font** | on | Off: set **Font**, **Size** (6–72), **Line height**, **Fallback font** and **Column width**. |
|
||||
|
||||
Changes apply to open sessions right away. Colours follow the IDE theme.
|
||||
|
||||
|
||||
@@ -79,26 +79,27 @@ OpenIDEA 会按项目记住终端标签页:各自的目录、自定义名称
|
||||
|
||||
**设置 › 工具 › 终端**:
|
||||
|
||||
| 设置 | 默认值 | 说明 |
|
||||
| ------------------------------ | ---------- | ----------------------------------------------------------------------------- |
|
||||
| **起始目录** | 项目根目录 | 相对路径按项目根目录解析。**在终端中打开** 仍会打开所选文件夹。项目级设置。 |
|
||||
| **环境变量** | 无 | 添加到新会话的环境中。项目级设置。 |
|
||||
| **Shell 路径** | 登录 Shell | 一条命令行,例如 `/bin/zsh --login`。**已安装的 Shell** 列出找到的 Shell。 |
|
||||
| **默认标签页名称** | `Local` | |
|
||||
| **响铃** | 开 | |
|
||||
| **会话结束时关闭** | 开 | |
|
||||
| **鼠标报告** | 开 | 关闭后程序无法捕获鼠标。 |
|
||||
| **选择时复制到剪贴板** | 关 | |
|
||||
| **点击鼠标中键时粘贴** | 开 | |
|
||||
| **右键单击时粘贴** | 关 | 开启后右键单击直接粘贴;按住 Ctrl 或 Shift 右键单击仍打开上下文菜单。 |
|
||||
| **按 Escape 将焦点移到编辑器** | 关 | 关闭时 `Esc` 发给 Shell。 |
|
||||
| **覆盖 IDE 快捷键** | 开 | 见上文。 |
|
||||
| **Shell 集成** | 开 | |
|
||||
| **高亮超链接** | 开 | |
|
||||
| **将 Option 用作 Meta 键** | 关 | 仅 macOS。 |
|
||||
| **光标形状** | 块 | 块、下划线或竖线。 |
|
||||
| **闪烁光标** | 开 | |
|
||||
| **使用编辑器字体** | 开 | 关闭后可设置 **字体**、**大小**(6–72)、**行高**、**备用字体** 和 **列宽**。 |
|
||||
| 设置 | 默认值 | 说明 |
|
||||
| ---------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| **起始目录** | 项目根目录 | 相对路径按项目根目录解析。**在终端中打开** 仍会打开所选文件夹。项目级设置。 |
|
||||
| **环境变量** | 无 | 添加到新会话的环境中。项目级设置。 |
|
||||
| **Shell 路径** | 登录 Shell | 一条命令行,例如 `/bin/zsh --login`。**已安装的 Shell** 列出找到的 Shell。 |
|
||||
| **默认标签页名称** | `Local` | |
|
||||
| **响铃** | 开 | |
|
||||
| **会话结束时关闭** | 开 | |
|
||||
| **鼠标报告** | 开 | 关闭后程序无法捕获鼠标。 |
|
||||
| **选择时复制到剪贴板** | 关 | |
|
||||
| **允许程序复制到剪贴板(OSC 52)** | 开 | tmux(`set-clipboard on`)、Neovim 等程序可以设置剪贴板,SSH 中也有效。程序无法读取剪贴板;超过 1 MiB 的内容会被忽略。 |
|
||||
| **点击鼠标中键时粘贴** | 开 | |
|
||||
| **右键单击时粘贴** | 关 | 开启后右键单击直接粘贴;按住 Ctrl 或 Shift 右键单击仍打开上下文菜单。 |
|
||||
| **按 Escape 将焦点移到编辑器** | 关 | 关闭时 `Esc` 发给 Shell。 |
|
||||
| **覆盖 IDE 快捷键** | 开 | 见上文。 |
|
||||
| **Shell 集成** | 开 | |
|
||||
| **高亮超链接** | 开 | |
|
||||
| **将 Option 用作 Meta 键** | 关 | 仅 macOS。 |
|
||||
| **光标形状** | 块 | 块、下划线或竖线。 |
|
||||
| **闪烁光标** | 开 | |
|
||||
| **使用编辑器字体** | 开 | 关闭后可设置 **字体**、**大小**(6–72)、**行高**、**备用字体** 和 **列宽**。 |
|
||||
|
||||
修改会立即应用到已打开的会话。配色跟随 IDE 主题。
|
||||
|
||||
|
||||
@@ -15716,6 +15716,8 @@ export type TerminalSettings = {
|
||||
closeOnExit?: boolean,
|
||||
mouseReporting?: boolean,
|
||||
copyOnSelection?: boolean,
|
||||
/** Programs may set the clipboard with OSC 52 (tmux, Neovim, TUIs over SSH); never read it. */
|
||||
osc52Clipboard?: boolean,
|
||||
pasteOnMiddleClick?: boolean,
|
||||
/** Right-click pastes instead of opening the context menu (Ctrl or Shift + right-click still opens it). */
|
||||
rightClickPaste?: boolean,
|
||||
|
||||
@@ -253,6 +253,11 @@ function TerminalOptions() {
|
||||
<BoundToggle k="terminal.closeOnExit" label="Close session when it ends" />
|
||||
<BoundToggle k="terminal.mouseReporting" label="Mouse reporting" />
|
||||
<BoundToggle k="terminal.copyOnSelection" label="Copy to clipboard on selection" />
|
||||
<BoundToggle
|
||||
k="terminal.osc52Clipboard"
|
||||
label="Let programs copy to the clipboard (OSC 52)"
|
||||
hint="For tmux, Neovim and other programs, also over SSH. Programs can't read the clipboard."
|
||||
/>
|
||||
<BoundToggle k="terminal.pasteOnMiddleClick" label="Paste on middle mouse button click" />
|
||||
<BoundToggle k="terminal.rightClickPaste" label="Paste on right click" />
|
||||
<BoundToggle
|
||||
@@ -846,6 +851,7 @@ export const TOOLS_PAGES: PageSpec[] = [
|
||||
"Close session when it ends",
|
||||
"Mouse reporting",
|
||||
"Copy to clipboard on selection",
|
||||
"Let programs copy to the clipboard (OSC 52)",
|
||||
"Paste on middle mouse button click",
|
||||
"Override IDE shortcuts",
|
||||
"Shell integration",
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { OSC52_MAX_BYTES, osc52Text } from "./osc52";
|
||||
|
||||
const b64 = (text: string) => btoa(String.fromCharCode(...new TextEncoder().encode(text)));
|
||||
|
||||
describe("osc52Text", () => {
|
||||
it("decodes the clipboard selection as UTF-8", () => {
|
||||
expect(osc52Text(`c;${b64("hello")}`)).toBe("hello");
|
||||
expect(osc52Text(`c;${b64("中文 ✓")}`)).toBe("中文 ✓");
|
||||
});
|
||||
|
||||
it("accepts the default, primary and select selections", () => {
|
||||
expect(osc52Text(`;${b64("x")}`)).toBe("x");
|
||||
expect(osc52Text(`p;${b64("x")}`)).toBe("x");
|
||||
expect(osc52Text(`s0;${b64("x")}`)).toBe("x");
|
||||
});
|
||||
|
||||
it("never answers a read request", () => {
|
||||
expect(osc52Text("c;?")).toBeNull();
|
||||
expect(osc52Text(";?")).toBeNull();
|
||||
});
|
||||
|
||||
it("ignores cut buffers only, invalid base64, empty and malformed payloads", () => {
|
||||
expect(osc52Text(`0;${b64("x")}`)).toBeNull();
|
||||
expect(osc52Text("c;not base64!")).toBeNull();
|
||||
expect(osc52Text("c;a")).toBeNull();
|
||||
expect(osc52Text("c;")).toBeNull();
|
||||
expect(osc52Text(b64("no selections"))).toBeNull();
|
||||
});
|
||||
|
||||
it("drops payloads over the size limit", () => {
|
||||
expect(osc52Text(`c;${btoa("a".repeat(OSC52_MAX_BYTES))}`)).toBe("a".repeat(OSC52_MAX_BYTES));
|
||||
expect(osc52Text(`c;${btoa("a".repeat(OSC52_MAX_BYTES + 1))}`)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* OSC 52 (`ESC ] 52 ; <selections> ; <base64> BEL`): a program that can't reach the local
|
||||
* clipboard (tmux with `set-clipboard on`, Neovim over SSH, TUI multiplexers) asks the terminal
|
||||
* to set it. Only writes are honoured: a read request (`?`) is never answered, as reading the
|
||||
* clipboard back would hand its contents to whatever runs in the terminal.
|
||||
*/
|
||||
|
||||
/** Decoded text larger than this is dropped. */
|
||||
export const OSC52_MAX_BYTES = 1 << 20;
|
||||
|
||||
const BASE64 = /^[A-Za-z0-9+/]*={0,2}$/;
|
||||
|
||||
/**
|
||||
* The text an OSC 52 payload (`<selections>;<base64>`) puts on the clipboard, or null for a read
|
||||
* request, cut buffers only, an oversized or invalid payload.
|
||||
*/
|
||||
export function osc52Text(data: string): string | null {
|
||||
const semi = data.indexOf(";");
|
||||
if (semi < 0) return null;
|
||||
const selections = data.slice(0, semi);
|
||||
const payload = data.slice(semi + 1).replace(/\s+/g, "");
|
||||
if (payload === "?" || !payload) return null;
|
||||
// Empty means the default (`s0`); clipboard, primary and selection all map to the one clipboard.
|
||||
if (selections && !/[cps]/.test(selections)) return null;
|
||||
if (payload.length % 4 === 1 || !BASE64.test(payload)) return null;
|
||||
if (Math.floor((payload.length * 3) / 4) > OSC52_MAX_BYTES + 2) return null;
|
||||
let binary: string;
|
||||
try {
|
||||
binary = atob(payload);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
if (binary.length > OSC52_MAX_BYTES) return null;
|
||||
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
||||
return new TextDecoder().decode(bytes);
|
||||
}
|
||||
@@ -37,7 +37,13 @@ const workbench = vi.hoisted(() => ({
|
||||
notify: vi.fn(),
|
||||
}));
|
||||
|
||||
const clipboard = vi.hoisted(() => ({ writeClipboardText: vi.fn(async (_text: string) => undefined) }));
|
||||
|
||||
vi.mock("@/platform/ipc", () => ({ call: ipc.call, commands: ipc.commands, isTauri: () => true }));
|
||||
vi.mock("@/platform/clipboard", async (importOriginal) => ({
|
||||
...(await importOriginal<object>()),
|
||||
writeClipboardText: clipboard.writeClipboardText,
|
||||
}));
|
||||
vi.mock("@/workbench/contributions", async (importOriginal) => ({
|
||||
...(await importOriginal<object>()),
|
||||
editorService: () => ({ openFile: workbench.openFile }),
|
||||
@@ -772,6 +778,25 @@ describe("terminal tab spinner state (#3831)", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("puts OSC 52 clipboard writes on the clipboard unless turned off, and never answers a read", async () => {
|
||||
const session = new TerminalSession({ key: "s-osc52", cwd: "/repo", onChange() {}, onFocus() {} });
|
||||
const b64 = (text: string) => btoa(String.fromCharCode(...new TextEncoder().encode(text)));
|
||||
try {
|
||||
clipboard.writeClipboardText.mockClear();
|
||||
await feed(session, `\x1b]52;c;${b64("复制 me")}\x07`);
|
||||
expect(clipboard.writeClipboardText).toHaveBeenCalledExactlyOnceWith("复制 me");
|
||||
await feed(session, "\x1b]52;c;?\x07");
|
||||
expect(clipboard.writeClipboardText).toHaveBeenCalledTimes(1);
|
||||
expect(ipc.commands.termWrite).not.toHaveBeenCalled();
|
||||
useProject.setState({ settings: { terminal: { osc52Clipboard: false } } } as never);
|
||||
await feed(session, `\x1b]52;c;${b64("off")}\x07`);
|
||||
expect(clipboard.writeClipboardText).toHaveBeenCalledTimes(1);
|
||||
} finally {
|
||||
useProject.setState({ settings: null });
|
||||
session.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
it("starts each command without the previous program's progress report", async () => {
|
||||
const session = new TerminalSession({ key: "s-progress-reset", cwd: "/repo", onChange() {}, onFocus() {} });
|
||||
try {
|
||||
|
||||
@@ -49,6 +49,7 @@ import { usePlatform } from "@/platform/platformInfo";
|
||||
import { workflowSettings, type TerminalSettingsValid } from "@/platform/workflowSettings";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
import type { CompletionInfo } from "./completion";
|
||||
import { osc52Text } from "./osc52";
|
||||
import {
|
||||
readLinkColor,
|
||||
readSearchDecorations,
|
||||
@@ -478,6 +479,16 @@ export class TerminalSession {
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
// OSC 52: a program sets the clipboard (writes only; see osc52.ts).
|
||||
this.term.parser.registerOscHandler(52, (data) => {
|
||||
if (!workflowSettings().terminal.osc52Clipboard) return true;
|
||||
const text = osc52Text(data);
|
||||
if (text !== null) {
|
||||
noteCopySource(text, { kind: "terminal", title: this.snapshot.appTitle ?? this.snapshot.title });
|
||||
void writeClipboardText(text).catch(() => undefined);
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
// OSC 9;4 (ConEmu-style progress): agent CLIs (Claude Code, Gemini CLI, …)
|
||||
// and long jobs report their own working state — state 0 removes it, 1–4
|
||||
// report work in flight. A program that reports progress decides the tab's
|
||||
|
||||
@@ -63,6 +63,7 @@ export const CLIENT_SETTINGS_KEYS = [
|
||||
"terminal.closeOnExit",
|
||||
"terminal.mouseReporting",
|
||||
"terminal.copyOnSelection",
|
||||
"terminal.osc52Clipboard",
|
||||
"terminal.pasteOnMiddleClick",
|
||||
"terminal.rightClickPaste",
|
||||
"terminal.overrideIdeShortcuts",
|
||||
|
||||
@@ -1268,6 +1268,8 @@
|
||||
"Copy revision number": "複製修訂號",
|
||||
"Copy to clipboard": "複製到剪貼簿",
|
||||
"Copy to clipboard on selection": "選擇時複製到剪貼簿",
|
||||
"For tmux, Neovim and other programs, also over SSH. Programs can't read the clipboard.": "適用於 tmux、Neovim 等程式,SSH 中也有效。程式無法讀取剪貼簿。",
|
||||
"Let programs copy to the clipboard (OSC 52)": "允許程式複製到剪貼簿(OSC 52)",
|
||||
"Copy with Header": "帶標題複製",
|
||||
"Copy/Paste": "複製/貼上",
|
||||
"Could not apply theme": "無法應用主題",
|
||||
|
||||
@@ -1762,6 +1762,8 @@
|
||||
"Copy revision number": "复制修订号",
|
||||
"Copy to clipboard": "复制到剪贴板",
|
||||
"Copy to clipboard on selection": "选择时复制到剪贴板",
|
||||
"For tmux, Neovim and other programs, also over SSH. Programs can't read the clipboard.": "适用于 tmux、Neovim 等程序,SSH 中也有效。程序无法读取剪贴板。",
|
||||
"Let programs copy to the clipboard (OSC 52)": "允许程序复制到剪贴板(OSC 52)",
|
||||
"Copy with Header": "带标题复制",
|
||||
"Copy/Paste": "复制/粘贴",
|
||||
"Could not apply theme": "无法应用主题",
|
||||
|
||||
@@ -204,6 +204,8 @@ export interface TerminalSettingsValid {
|
||||
closeOnExit: boolean;
|
||||
mouseReporting: boolean;
|
||||
copyOnSelection: boolean;
|
||||
/** Programs may set the clipboard with OSC 52 (tmux, Neovim, TUIs over SSH); never read it. */
|
||||
osc52Clipboard: boolean;
|
||||
pasteOnMiddleClick: boolean;
|
||||
/** Right-click pastes instead of opening the context menu (Ctrl or Shift + right-click still opens it). */
|
||||
rightClickPaste: boolean;
|
||||
@@ -442,6 +444,7 @@ export const DEFAULT_WORKFLOW: WorkflowSettings = {
|
||||
closeOnExit: true,
|
||||
mouseReporting: true,
|
||||
copyOnSelection: false,
|
||||
osc52Clipboard: true,
|
||||
pasteOnMiddleClick: true,
|
||||
rightClickPaste: false,
|
||||
overrideIdeShortcuts: true,
|
||||
@@ -688,6 +691,7 @@ export function validateTerminal(raw: unknown): TerminalSettingsValid {
|
||||
closeOnExit: bool(v.closeOnExit, d.closeOnExit),
|
||||
mouseReporting: bool(v.mouseReporting, d.mouseReporting),
|
||||
copyOnSelection: bool(v.copyOnSelection, d.copyOnSelection),
|
||||
osc52Clipboard: bool(v.osc52Clipboard, d.osc52Clipboard),
|
||||
pasteOnMiddleClick: bool(v.pasteOnMiddleClick, d.pasteOnMiddleClick),
|
||||
rightClickPaste: bool(v.rightClickPaste, d.rightClickPaste),
|
||||
overrideIdeShortcuts: bool(v.overrideIdeShortcuts, d.overrideIdeShortcuts),
|
||||
|
||||
Reference in new issue
Заблокувати користувача