дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-28 05:22:23 +02:00
Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
29180f8aa9 |
No files matched your search
@@ -56,6 +56,7 @@ The pane's context menu has **Copy**, **Paste**, **Select All**, **Clear Buffer*
|
||||
|
||||
- `http`, `https` and `file` URLs open in your browser. OSC 8 hyperlinks from programs work too.
|
||||
- File locations such as `src/main.rs:42:7` or `Main.java(42,7)` open in the editor at that line. Paths resolve against the shell's current directory, then by file name across the project.
|
||||
- Hold `⌘` (`Ctrl` on Windows/Linux) and hover over an existing file or folder name (`README.md`, `src/features`, `/tmp`) to turn it into a link: clicking opens files in an editor tab of the current window, opens project folders in the **Project** tool window, and reveals folders outside the project in Finder / Explorer / Files.
|
||||
- Pasting copied files pastes their paths, quoted for the shell in use (bash/zsh/fish, PowerShell or cmd). Pasting an image from the clipboard saves it to a file and pastes that file's path.
|
||||
- Dropping files from your file manager onto the terminal types their quoted paths at the prompt. They are not run.
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ OpenIDEA 会按项目记住终端标签页:各自的目录、自定义名称
|
||||
|
||||
- `http`、`https` 和 `file` 链接在浏览器中打开,程序输出的 OSC 8 超链接同样可用。
|
||||
- `src/main.rs:42:7`、`Main.java(42,7)` 这类文件位置会在编辑器中打开并定位到该行。路径先按 Shell 的当前目录解析,找不到时再在整个项目中按文件名查找。
|
||||
- 按住 `⌘`(Windows/Linux 上为 `Ctrl`)将鼠标悬停在已存在的文件名或文件夹名(如 `README.md`、`src/features`、`/tmp`)上会变为超链接:点击文件会在当前窗口的编辑器标签页中打开,项目内的文件夹会在左侧 **项目** 视图中展开并选中,项目外的文件夹则会在访达 / 资源管理器 / 文件管理器中显示。
|
||||
- 粘贴复制的文件时,会粘贴按当前 Shell(bash/zsh/fish、PowerShell 或 cmd)规则加好引号的路径。粘贴剪贴板中的图片时,会先保存为文件,再粘贴该文件的路径。
|
||||
- 从文件管理器把文件拖到终端,会在提示符处输入加了引号的路径,但不会执行。
|
||||
|
||||
|
||||
@@ -468,3 +468,158 @@ test("dragging terminal tabs into editor strips and split edges preserves live s
|
||||
});
|
||||
expect(await page.evaluate(() => (window as unknown as { __killedPtys: number[] }).__killedPtys)).toEqual([]);
|
||||
});
|
||||
|
||||
test("⌘+hover turns existing terminal files and folders into hyperlinks and routes clicks by target kind and project scope", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const handlers = window.__ipc.handlers;
|
||||
let id = 0;
|
||||
const revealed: string[][] = [];
|
||||
(window as unknown as { __revealedInFinder: string[][] }).__revealedInFinder = revealed;
|
||||
const entries: Record<string, "file" | "dir"> = {
|
||||
"/dev/acme-api/App.tsx": "file",
|
||||
"/dev/acme-api/src": "dir",
|
||||
"/tmp/outside.log": "file",
|
||||
"/tmp/outside-dir": "dir",
|
||||
};
|
||||
handlers.term_default_shell = () => "/bin/zsh";
|
||||
handlers.term_available_shells = () => ["/bin/zsh"];
|
||||
handlers.term_spawn = () => ({ id: ++id, title: "zsh", pid: id });
|
||||
handlers.term_resize = () => null;
|
||||
handlers.term_write = () => null;
|
||||
handlers.term_is_busy = () => false;
|
||||
handlers.term_kill = () => null;
|
||||
handlers.fs_entry_kind = (args) => {
|
||||
const p = String(args.path ?? "");
|
||||
if (p in entries) return entries[p];
|
||||
throw { kind: "notFound", message: `No such entry: ${p}` };
|
||||
};
|
||||
handlers.fs_read_dir = (args) => {
|
||||
if (args.path === "/dev/acme-api/src") {
|
||||
return [{ name: "main.ts", path: "/dev/acme-api/src/main.ts", kind: "file", ignored: false }];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
handlers.find_files = () => [];
|
||||
handlers["plugin:opener|reveal_item_in_dir"] = (args) => {
|
||||
revealed.push(args.paths as string[]);
|
||||
return null;
|
||||
};
|
||||
|
||||
const store = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(store);
|
||||
layout.hideToolWindow("project");
|
||||
layout.setToolWindowSize("bottom", 240);
|
||||
layout.showToolWindow("terminal", true);
|
||||
});
|
||||
|
||||
const terminal = page.getByRole("region", { name: "Terminal", exact: true });
|
||||
await expect(terminal.locator(".xterm-helper-textarea")).toBeFocused();
|
||||
|
||||
// Row 0 has all 6 cases: in-project file, non-existent file, in-project dir, non-existent dir,
|
||||
// out-of-project file, out-of-project dir, and non-existent out-of-project dir.
|
||||
const line = "App.tsx missing.ts src no_dir/ /tmp/outside.log /tmp/outside-dir /tmp/nope";
|
||||
await page.evaluate(async (text) => {
|
||||
const store = "/src/features/terminal/store.ts";
|
||||
const rt = await import(store);
|
||||
const s = rt.getSession(rt.useTerminals.getState().tabs[0]!.session)!;
|
||||
s.term.reset();
|
||||
await new Promise<void>((done) => s.term.write(`${text}\r\n`, done));
|
||||
}, line);
|
||||
|
||||
const screen = terminal.locator(".xterm-screen");
|
||||
const pointFor = async (token: string) => {
|
||||
const startCol = line.indexOf(token);
|
||||
const box = (await screen.boundingBox())!;
|
||||
const dims = await page.evaluate(async () => {
|
||||
const store = "/src/features/terminal/store.ts";
|
||||
const rt = await import(store);
|
||||
const { term } = rt.getSession(rt.useTerminals.getState().tabs[0]!.session)!;
|
||||
return { cols: term.cols, rows: term.rows };
|
||||
});
|
||||
return {
|
||||
x: box.x + ((startCol + Math.min(2, token.length / 2)) / dims.cols) * box.width,
|
||||
y: box.y + (0.5 / dims.rows) * box.height,
|
||||
};
|
||||
};
|
||||
|
||||
const pathLink = terminal.locator(".openidea-terminal-path-link");
|
||||
const editorTabs = page.getByRole("tablist", { name: "Editor tabs" });
|
||||
|
||||
// 1) Hover & click `App.tsx` WITHOUT ⌘: no link decoration and no editor tab opens.
|
||||
const appPt = await pointFor("App.tsx");
|
||||
await page.mouse.move(appPt.x, appPt.y);
|
||||
await expect(pathLink).toHaveCount(0);
|
||||
await page.mouse.click(appPt.x, appPt.y);
|
||||
await expect(editorTabs).toHaveCount(0);
|
||||
|
||||
// 2) Press ⌘ while already hovering `App.tsx`: becomes a hyperlink; ⌘+click opens `App.tsx` in editor!
|
||||
await page.keyboard.down("Meta");
|
||||
await expect(pathLink).toHaveCount(1);
|
||||
if (process.env.OPENIDEA_TERMINAL_SHOTS)
|
||||
await page.screenshot({
|
||||
path: `${process.env.OPENIDEA_TERMINAL_SHOTS}/pr3-hover-file.png`,
|
||||
animations: "disabled",
|
||||
});
|
||||
await page.mouse.click(appPt.x, appPt.y);
|
||||
await page.keyboard.up("Meta");
|
||||
await expect(editorTabs.getByRole("tab", { name: "App.tsx", selected: true })).toBeVisible();
|
||||
|
||||
// 3) Non-existent targets (`missing.ts`, `no_dir/`, `/tmp/nope`) do NOT turn into links on ⌘+hover or ⌘+click.
|
||||
for (const absent of ["missing.ts", "no_dir/", "/tmp/nope"]) {
|
||||
const pt = await pointFor(absent);
|
||||
await page.keyboard.down("Meta");
|
||||
await page.mouse.move(pt.x, pt.y);
|
||||
await expect(pathLink).toHaveCount(0);
|
||||
await page.mouse.click(pt.x, pt.y);
|
||||
await page.keyboard.up("Meta");
|
||||
}
|
||||
await expect(editorTabs.getByRole("tab")).toHaveText(["App.tsx"]);
|
||||
|
||||
// 4) Out-of-project existing file (`/tmp/outside.log`) opens in an editor tab of the current window.
|
||||
const outFilePt = await pointFor("/tmp/outside.log");
|
||||
await page.keyboard.down("Meta");
|
||||
await page.mouse.move(outFilePt.x, outFilePt.y);
|
||||
await expect(pathLink).toHaveCount(1);
|
||||
await page.mouse.click(outFilePt.x, outFilePt.y);
|
||||
await page.keyboard.up("Meta");
|
||||
await expect(editorTabs.getByRole("tab", { name: "outside.log", selected: true })).toBeVisible();
|
||||
|
||||
// 5) In-project folder (`src`) opens the Project tool window on the left, expands `src`, and selects it.
|
||||
const projectRegion = page.getByRole("region", { name: "Project", exact: true });
|
||||
await expect(projectRegion).toBeHidden();
|
||||
const srcPt = await pointFor("src");
|
||||
await page.keyboard.down("Meta");
|
||||
await page.mouse.move(srcPt.x, srcPt.y);
|
||||
await expect(pathLink).toHaveCount(1);
|
||||
if (process.env.OPENIDEA_TERMINAL_SHOTS)
|
||||
await page.screenshot({
|
||||
path: `${process.env.OPENIDEA_TERMINAL_SHOTS}/pr3-hover-folder.png`,
|
||||
animations: "disabled",
|
||||
});
|
||||
await page.mouse.click(srcPt.x, srcPt.y);
|
||||
await page.keyboard.up("Meta");
|
||||
await expect(projectRegion).toBeVisible();
|
||||
const srcItem = projectRegion.getByRole("treeitem", { name: "src", exact: true });
|
||||
await expect(srcItem).toHaveAttribute("aria-expanded", "true");
|
||||
await expect(srcItem).toHaveAttribute("aria-selected", "true");
|
||||
await expect(projectRegion.getByRole("treeitem", { name: "main.ts", exact: true })).toBeVisible();
|
||||
if (process.env.OPENIDEA_TERMINAL_SHOTS)
|
||||
await page.screenshot({
|
||||
path: `${process.env.OPENIDEA_TERMINAL_SHOTS}/pr3-opened-folder.png`,
|
||||
animations: "disabled",
|
||||
});
|
||||
|
||||
// 6) Out-of-project folder (`/tmp/outside-dir`) reveals in Finder instead of changing Project selection.
|
||||
const outDirPt = await pointFor("/tmp/outside-dir");
|
||||
await page.keyboard.down("Meta");
|
||||
await page.mouse.move(outDirPt.x, outDirPt.y);
|
||||
await expect(pathLink).toHaveCount(1);
|
||||
await page.mouse.click(outDirPt.x, outDirPt.y);
|
||||
await page.keyboard.up("Meta");
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => (window as unknown as { __revealedInFinder: string[][] }).__revealedInFinder))
|
||||
.toEqual([["/tmp/outside-dir"]]);
|
||||
});
|
||||
@@ -41,6 +41,7 @@ import { showNewPopup, treeHandle } from "./ProjectView";
|
||||
import { lastFileRefactoring, undoFileRefactoring } from "./fileRefactor";
|
||||
import {
|
||||
VIEW_MODES,
|
||||
canRevealInProjectTree,
|
||||
collapseAll,
|
||||
currentModel,
|
||||
expandAll,
|
||||
@@ -105,12 +106,12 @@ function showProjectView(focus: boolean) {
|
||||
}
|
||||
|
||||
/** Selects `path` (default: the active editor's file) in the project view. */
|
||||
export function selectInProjectView(path?: string | null, focus = true) {
|
||||
export function selectInProjectView(path?: string | null, focus = true, expand = false) {
|
||||
const target = path ?? maybeEditorService()?.activePath() ?? null;
|
||||
if (!target) return false;
|
||||
if (!modeShows(target)) setViewMode("project");
|
||||
showProjectView(focus);
|
||||
return revealPath(target, focus, true);
|
||||
return revealPath(target, focus, true, expand);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +227,12 @@ export function registerProjectActions(): () => void {
|
||||
keywords: ["locate", "reveal", "show in"],
|
||||
run: ({ arg }) => {
|
||||
const path = typeof arg === "string" ? arg : (arg as { path?: string } | undefined)?.path;
|
||||
if (path) return void selectInProjectView(path);
|
||||
const opts =
|
||||
typeof arg === "object" && arg ? (arg as { expand?: boolean; revealOutside?: boolean }) : undefined;
|
||||
if (path) {
|
||||
if (opts?.revealOutside && !canRevealInProjectTree(path)) return revealInFinder(nodesFrom(path));
|
||||
return void selectInProjectView(path, true, !!opts?.expand);
|
||||
}
|
||||
const target = maybeEditorService()?.activePath() ?? leadNode()?.path;
|
||||
if (target) showSelectIn(target);
|
||||
},
|
||||
|
||||
@@ -151,4 +151,25 @@ describe("Select In (⌥F1)", () => {
|
||||
await executeAction("navigate.selectIn", { path: "/p/src/a.ts" });
|
||||
expect(useContextMenuStore.getState().menu).toBeNull();
|
||||
});
|
||||
|
||||
it("expands an in-project folder when expand is true and reveals out-of-project folders in the file manager", async () => {
|
||||
const { useProjectTree } = await import("./store");
|
||||
const prev = useProjectTree.getState();
|
||||
disposers.push(
|
||||
registerProjectActions(),
|
||||
() => setContext("projectOpen", false),
|
||||
() => useProjectTree.setState(prev),
|
||||
);
|
||||
setContext("projectOpen", true);
|
||||
useProjectTree.setState({ root: "/p", expanded: new Set(["/p"]) });
|
||||
|
||||
await executeAction("navigate.selectIn", { path: "/p/src/features", expand: true, revealOutside: true });
|
||||
expect(useProjectTree.getState().expanded.has("/p/src")).toBe(true);
|
||||
expect(useProjectTree.getState().expanded.has("/p/src/features")).toBe(true);
|
||||
expect(useProjectTree.getState().revealRequest).toMatchObject({ path: "/p/src/features", focus: true });
|
||||
expect(revealItemInDir).not.toHaveBeenCalled();
|
||||
|
||||
await executeAction("navigate.selectIn", { path: "/tmp/outside-dir", expand: true, revealOutside: true });
|
||||
expect(revealItemInDir).toHaveBeenCalledExactlyOnceWith("/tmp/outside-dir");
|
||||
});
|
||||
});
|
||||
@@ -753,11 +753,9 @@ export function dropOutlines(paths: readonly string[]) {
|
||||
|
||||
let revealSeq = 0;
|
||||
|
||||
/** Expands the ancestors of `path` and selects it once visible. */
|
||||
export function revealPath(requested: string, focus = false, explain = false) {
|
||||
const { expanded } = get();
|
||||
function resolveRevealTarget(requested: string): { path: string; root: string } | null {
|
||||
const project = get().root;
|
||||
if (!project) return false;
|
||||
if (!project) return null;
|
||||
// Registered archive roots by their `/`-separated form, which candidate paths use.
|
||||
const archiveRoots = new Map(
|
||||
extraFolders(projectViewRoots(useProjectViewRoots.getState().roots)).flatMap((r) =>
|
||||
@@ -772,12 +770,26 @@ export function revealPath(requested: string, focus = false, explain = false) {
|
||||
};
|
||||
// Library documents (`jdt://`, `jar:` URIs) are shown as entries of their archive under External Libraries.
|
||||
const path = [requested, ...libraryEntryPaths(requested, archives)].find((p) => rootOf(p) !== null);
|
||||
if (!path) return false;
|
||||
const root = rootOf(path)!;
|
||||
return path ? { path, root: rootOf(path)! } : null;
|
||||
}
|
||||
|
||||
/** Whether `requested` lies inside any root the Project tree can show. */
|
||||
export function canRevealInProjectTree(requested: string): boolean {
|
||||
return resolveRevealTarget(requested) !== null;
|
||||
}
|
||||
|
||||
/** Expands the ancestors of `path` (and `path` itself when `expand` is true) and selects it once visible. */
|
||||
export function revealPath(requested: string, focus = false, explain = false, expand = false) {
|
||||
const resolved = resolveRevealTarget(requested);
|
||||
if (!resolved) return false;
|
||||
const { path, root } = resolved;
|
||||
const { expanded } = get();
|
||||
const project = get().root!;
|
||||
// Library folders sit below group nodes (External Libraries › SDK), keyed in their own namespace.
|
||||
const model = currentModel();
|
||||
const rootKey = root === project ? root : (model.keyOfPath.get(root) ?? root);
|
||||
const folders = ancestorsWithin(root, path);
|
||||
const baseFolders = ancestorsWithin(root, path);
|
||||
const folders = expand && !baseFolders.includes(path) ? [...baseFolders, path] : baseFolders;
|
||||
const ancestors = [...groupAncestors(model, rootKey), ...folders.map((a) => keyLike(rootKey, a))];
|
||||
const next = new Set(expanded);
|
||||
let changed = false;
|
||||
|
||||
@@ -26,15 +26,17 @@ import { findTerminalLinks } from "./links";
|
||||
import { LINK_HANDLER, fontFor, openExternal, openFileLink } from "./session";
|
||||
import { MIN_CONTRAST_RATIO, readLinkColor, readTerminalTheme, remeasureWhenFontsLoad } from "./theme";
|
||||
import { installLinkHighlights, xtermLink, type LinkHighlightController } from "./linkHighlights";
|
||||
import { installModifierPathLinks, type ModifierPathLinksController } from "./pathLinks";
|
||||
|
||||
const live = new Map<Terminal, LinkHighlightController>();
|
||||
const live = new Map<Terminal, { links: LinkHighlightController; paths: ModifierPathLinksController }>();
|
||||
|
||||
/** Follows a theme change (called with the terminal sessions' own update). */
|
||||
export function applyThemeToEmbedded() {
|
||||
const theme = readTerminalTheme();
|
||||
for (const [t, links] of live) {
|
||||
for (const [t, { links, paths }] of live) {
|
||||
t.options.theme = theme;
|
||||
links.refresh();
|
||||
paths.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +87,12 @@ export function createEmbeddedTerminal(host: HTMLElement, opts: EmbeddedTerminal
|
||||
});
|
||||
const fit = new FitAddon();
|
||||
term.loadAddon(fit);
|
||||
live.set(term, installLinkHighlights(term, readLinkColor));
|
||||
const linkHighlights = installLinkHighlights(term, readLinkColor);
|
||||
const pathLinks = installModifierPathLinks(term, host, {
|
||||
cwd: () => opts.cwd ?? useProject.getState().project?.root ?? "",
|
||||
color: readLinkColor,
|
||||
});
|
||||
live.set(term, { links: linkHighlights, paths: pathLinks });
|
||||
let lastSize = { cols: term.cols, rows: term.rows };
|
||||
const processResize = settledResize((cols, rows) => {
|
||||
if (cols === lastSize.cols && rows === lastSize.rows) return;
|
||||
@@ -153,7 +160,9 @@ export function createEmbeddedTerminal(host: HTMLElement, opts: EmbeddedTerminal
|
||||
removePaste();
|
||||
removeDrop();
|
||||
for (const d of disposables) d.dispose();
|
||||
live.get(term)?.dispose();
|
||||
const controllers = live.get(term);
|
||||
controllers?.links.dispose();
|
||||
controllers?.paths.dispose();
|
||||
live.delete(term);
|
||||
term.dispose();
|
||||
},
|
||||
|
||||
@@ -16,7 +16,10 @@ import { findTerminalLinks, type TerminalLink } from "./links";
|
||||
export const LINK_DECORATION_CLASS = "openidea-terminal-link";
|
||||
|
||||
/** 0-based cell columns `[start, end)` of `link` (string offsets) in `line`; wide CJK glyphs take two cells. */
|
||||
export function linkCells(line: IBufferLine, link: TerminalLink): { start: number; end: number } {
|
||||
export function linkCells(
|
||||
line: IBufferLine,
|
||||
link: Pick<TerminalLink, "start" | "end">,
|
||||
): { start: number; end: number } {
|
||||
return { start: stringOffsetToCol(line, link.start), end: stringOffsetToCol(line, link.end) };
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,13 @@ export type TerminalLink =
|
||||
| { kind: "url"; start: number; end: number; text: string; url: string }
|
||||
| { kind: "file"; start: number; end: number; text: string; path: string; line?: number; col?: number };
|
||||
|
||||
export interface PathCandidate {
|
||||
start: number;
|
||||
end: number;
|
||||
text: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
const URL_RE = /\b(?:https?|file):\/\/[^\s<>"'`]+/g;
|
||||
|
||||
// `src/main.rs:10:5`, `./a/b.ts:3`, `/abs/x.py:12`, `foo.go(12,3)`, `Foo.kt:22`,
|
||||
@@ -104,3 +111,100 @@ export function resolvePath(path: string, cwd: string, home?: string | null): st
|
||||
// A Windows drive prefix is its own root; POSIX results keep the leading slash.
|
||||
return /^[A-Za-z]:\//.test(joined) ? joined : `/${joined}`;
|
||||
}
|
||||
|
||||
const LEADING_WRAP = new Set(['"', "'", "`", "(", "[", "{", "<"]);
|
||||
const TRAILING_PUNCT = new Set(['"', "'", "`", "}", ">", ",", ";", "!", "?"]);
|
||||
|
||||
function normalizeCandidatePath(raw: string): string {
|
||||
if (raw === "/" || raw === "\\" || /^[A-Za-z]:[\\/]$/.test(raw)) return raw;
|
||||
return raw.replace(/[\\/]+$/, "");
|
||||
}
|
||||
|
||||
function isPlausiblePathCandidate(raw: string, quoted = false): boolean {
|
||||
if (!raw || raw.length > 512) return false;
|
||||
if (raw === "." || raw === "..") return false;
|
||||
if (raw.startsWith("-") || raw === "+" || raw === "+++") return false;
|
||||
if (quoted && (raw.match(/\s/g)?.length ?? 0) > 6) return false;
|
||||
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(raw) || /^(?:mailto|javascript|data):/i.test(raw)) return false;
|
||||
if (/^[\w.-]+@[\w.-]+:/.test(raw)) return false;
|
||||
if (!/[\p{L}\p{N}_]/u.test(raw)) return false;
|
||||
if (/^\d+$/.test(raw) || /^\d{1,2}:\d{2}(?::\d{2})?$/.test(raw)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function trimTokenBounds(text: string, from: number, to: number): { start: number; end: number } {
|
||||
let start = from;
|
||||
let end = to;
|
||||
// Strip `flag=path` / `KEY=path` prefixes (`--config=src/a.json`, `OUT_DIR=/tmp/out`).
|
||||
const eq = /^(--?[\w-]+|[A-Za-z_]\w*)=/.exec(text.slice(start, end));
|
||||
if (eq && start + eq[0].length < end) start += eq[0].length;
|
||||
|
||||
while (start < end && LEADING_WRAP.has(text[start]!)) start++;
|
||||
for (; end > start;) {
|
||||
const ch = text[end - 1]!;
|
||||
if (TRAILING_PUNCT.has(ch)) {
|
||||
end--;
|
||||
continue;
|
||||
}
|
||||
if (ch === ":" && !(end - start === 2 && /^[A-Za-z]:$/.test(text.slice(start, end)))) {
|
||||
end--;
|
||||
continue;
|
||||
}
|
||||
if (ch === "." && text.slice(start, end) !== "." && text.slice(start, end) !== "..") {
|
||||
end--;
|
||||
continue;
|
||||
}
|
||||
if (ch === ")" || ch === "]") {
|
||||
const open = ch === ")" ? "(" : "[";
|
||||
const slice = text.slice(start, end);
|
||||
const opens = slice.split(open).length - 1;
|
||||
const closes = slice.split(ch).length - 1;
|
||||
if (closes > opens) {
|
||||
end--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return { start, end };
|
||||
}
|
||||
|
||||
/**
|
||||
* Bare file and folder path candidates on a terminal line (`README.md`, `src/`,
|
||||
* `crates/ide-host`, `/tmp/logs`, `"my dir/file.ts"`), excluding spans already
|
||||
* claimed by URL or `path:line[:col]` links. Ordered longest-first when nested
|
||||
* (e.g. a quoted spaced path ahead of its inner whitespace-split tokens).
|
||||
*/
|
||||
export function findPathCandidates(text: string, existing = findTerminalLinks(text)): PathCandidate[] {
|
||||
const overlapsLink = (s: number, e: number) => existing.some((l) => s < l.end && e > l.start);
|
||||
const seen = new Set<string>();
|
||||
const out: PathCandidate[] = [];
|
||||
const push = (start: number, end: number, quoted: boolean) => {
|
||||
if (end <= start || overlapsLink(start, end)) return;
|
||||
const slice = text.slice(start, end);
|
||||
if (!isPlausiblePathCandidate(slice, quoted)) return;
|
||||
const key = `${start}:${end}`;
|
||||
if (seen.has(key)) return;
|
||||
seen.add(key);
|
||||
out.push({ start, end, text: slice, path: slice });
|
||||
};
|
||||
|
||||
for (const m of text.matchAll(/(['"`])([^'"`\r\n]{1,256})\1/g)) {
|
||||
const inner = m[2]!;
|
||||
const trimmed = inner.trim();
|
||||
if (!trimmed) continue;
|
||||
const lead = inner.indexOf(trimmed);
|
||||
const start = m.index + 1 + lead;
|
||||
const end = start + trimmed.length;
|
||||
push(start, end, true);
|
||||
}
|
||||
|
||||
for (const m of text.matchAll(/\S+/g)) {
|
||||
const { start, end } = trimTokenBounds(text, m.index, m.index + m[0].length);
|
||||
push(start, end, false);
|
||||
}
|
||||
|
||||
return out.sort((a, b) => a.start - b.start || b.end - b.start - (a.end - a.start));
|
||||
}
|
||||
|
||||
export { normalizeCandidatePath };
|
||||
@@ -0,0 +1,313 @@
|
||||
// @vitest-environment jsdom
|
||||
import { Terminal, type IDecoration, type IDecorationOptions } from "@xterm/xterm";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { registerActions } from "@/platform/actions";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { findPathCandidates } from "./links";
|
||||
import {
|
||||
PATH_HOVER_CLASS,
|
||||
_resetPathLinksHomeForTests,
|
||||
installModifierPathLinks,
|
||||
isPathLinkModifier,
|
||||
openPathTarget,
|
||||
resolvePathTarget,
|
||||
} from "./pathLinks";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
highlightHyperlinks: true,
|
||||
entryKinds: new Map<string, "file" | "dir">(),
|
||||
findFiles: vi.fn<(_q: string, _limit: number) => Promise<Array<{ path: string; relPath: string }>>>(async () => []),
|
||||
openFile: vi.fn(async (_path: string, _opts?: unknown) => undefined),
|
||||
revealInFileManager: vi.fn(async (_path: string) => true),
|
||||
homeDir: "/Users/alice",
|
||||
}));
|
||||
|
||||
vi.mock("@/platform/ipc", () => ({
|
||||
isTauri: () => true,
|
||||
call: async <T>(p: Promise<T>) => p,
|
||||
commands: {
|
||||
fsEntryKind: vi.fn(async (path: string) => {
|
||||
const kind = mocks.entryKinds.get(path);
|
||||
if (!kind) throw new Error(`ENOENT: ${path}`);
|
||||
return kind;
|
||||
}),
|
||||
findFiles: (q: string, limit: number) => mocks.findFiles(q, limit),
|
||||
},
|
||||
}));
|
||||
vi.mock("@tauri-apps/api/path", () => ({
|
||||
homeDir: async () => mocks.homeDir,
|
||||
}));
|
||||
vi.mock("@/platform/fileManager", () => ({
|
||||
revealInFileManager: (path: string) => mocks.revealInFileManager(path),
|
||||
}));
|
||||
vi.mock("@/platform/workflowSettings", () => ({
|
||||
workflowSettings: () => ({ terminal: { highlightHyperlinks: mocks.highlightHyperlinks } }),
|
||||
}));
|
||||
vi.mock("@/workbench/contributions", async (importOriginal) => ({
|
||||
...(await importOriginal<object>()),
|
||||
editorService: () => ({ openFile: mocks.openFile }),
|
||||
}));
|
||||
|
||||
import { commands } from "@/platform/ipc";
|
||||
|
||||
const write = (term: Terminal, data: string) => new Promise<void>((resolve) => term.write(data, resolve));
|
||||
|
||||
describe("findPathCandidates", () => {
|
||||
it("extracts bare files, folders, flags=path and quoted spaced paths while skipping URLs, file:line and numbers", () => {
|
||||
const line =
|
||||
'drwxr-xr-x 12 4096 22:10 README.md src/ --config=config/app.json "my dir/hello world.ts" https://a.dev a.rs:10:2 -la . ..';
|
||||
const got = findPathCandidates(line).map((c) => c.path);
|
||||
expect(got).toContain("README.md");
|
||||
expect(got).toContain("src/");
|
||||
expect(got).toContain("config/app.json");
|
||||
expect(got).toContain("my dir/hello world.ts");
|
||||
expect(got).not.toContain("4096");
|
||||
expect(got).not.toContain("22:10");
|
||||
expect(got).not.toContain("-la");
|
||||
expect(got).not.toContain(".");
|
||||
expect(got).not.toContain("..");
|
||||
expect(got).not.toContain("https://a.dev");
|
||||
expect(got).not.toContain("a.rs:10:2");
|
||||
});
|
||||
|
||||
it("orders an outer quoted path ahead of inner tokens so spaced paths win when they exist and prose falls back when not", () => {
|
||||
const candidates = findPathCandidates('"see src/App.tsx now"');
|
||||
expect(candidates[0]?.path).toBe("see src/App.tsx now");
|
||||
expect(candidates.map((c) => c.path)).toContain("src/App.tsx");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isPathLinkModifier", () => {
|
||||
it("requires ⌘ on macOS and Ctrl on Windows/Linux without competing modifiers", () => {
|
||||
expect(isPathLinkModifier({ metaKey: true, ctrlKey: false, altKey: false }, "macos")).toBe(true);
|
||||
expect(isPathLinkModifier({ metaKey: false, ctrlKey: true, altKey: false }, "macos")).toBe(false);
|
||||
expect(isPathLinkModifier({ metaKey: true, ctrlKey: false, altKey: true }, "macos")).toBe(false);
|
||||
|
||||
expect(isPathLinkModifier({ metaKey: false, ctrlKey: true, altKey: false }, "linux")).toBe(true);
|
||||
expect(isPathLinkModifier({ metaKey: false, ctrlKey: true, altKey: false }, "windows")).toBe(true);
|
||||
expect(isPathLinkModifier({ metaKey: true, ctrlKey: false, altKey: false }, "windows")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolvePathTarget — existence & project-scope matrix", () => {
|
||||
beforeEach(() => {
|
||||
mocks.entryKinds.clear();
|
||||
mocks.findFiles.mockReset().mockResolvedValue([]);
|
||||
_resetPathLinksHomeForTests();
|
||||
useProject.setState({ project: { root: "/repo" } as never });
|
||||
});
|
||||
afterEach(() => {
|
||||
useProject.setState({ project: null, settings: null });
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("resolves existing in-project files and folders relative to cwd or project root", async () => {
|
||||
mocks.entryKinds.set("/repo/sub/local.ts", "file");
|
||||
mocks.entryKinds.set("/repo/src/features", "dir");
|
||||
mocks.entryKinds.set("/repo/Makefile", "file");
|
||||
|
||||
expect(await resolvePathTarget("local.ts", "/repo/sub")).toEqual({ kind: "file", path: "/repo/sub/local.ts" });
|
||||
expect(await resolvePathTarget("Makefile", "/repo/sub")).toEqual({ kind: "file", path: "/repo/Makefile" });
|
||||
expect(await resolvePathTarget("src/features/", "/repo/sub")).toEqual({ kind: "dir", path: "/repo/src/features" });
|
||||
});
|
||||
|
||||
it("returns null for non-existent in-project files and folders, and rejects file/ with a trailing slash", async () => {
|
||||
mocks.entryKinds.set("/repo/README.md", "file");
|
||||
expect(await resolvePathTarget("missing.ts", "/repo")).toBeNull();
|
||||
expect(await resolvePathTarget("missing_dir", "/repo")).toBeNull();
|
||||
expect(await resolvePathTarget("missing_dir/", "/repo")).toBeNull();
|
||||
expect(await resolvePathTarget("README.md/", "/repo")).toBeNull();
|
||||
});
|
||||
|
||||
it("resolves existing out-of-project files and folders (absolute, ../, and ~), and returns null when absent", async () => {
|
||||
mocks.entryKinds.set("/tmp/outside.log", "file");
|
||||
mocks.entryKinds.set("/tmp/outside-dir", "dir");
|
||||
mocks.entryKinds.set("/Users/alice/Downloads", "dir");
|
||||
mocks.entryKinds.set("/sibling/notes.txt", "file");
|
||||
mocks.findFiles.mockResolvedValue([{ path: "/repo/src/outside.log", relPath: "src/outside.log" }]);
|
||||
|
||||
expect(await resolvePathTarget("/tmp/outside.log", "/repo")).toEqual({ kind: "file", path: "/tmp/outside.log" });
|
||||
expect(await resolvePathTarget("/tmp/outside-dir", "/repo")).toEqual({ kind: "dir", path: "/tmp/outside-dir" });
|
||||
expect(await resolvePathTarget("~/Downloads", "/repo")).toEqual({ kind: "dir", path: "/Users/alice/Downloads" });
|
||||
expect(await resolvePathTarget("../sibling/notes.txt", "/repo")).toEqual({
|
||||
kind: "file",
|
||||
path: "/sibling/notes.txt",
|
||||
});
|
||||
|
||||
// Explicit paths that do not exist must NEVER fall back to `findFiles` inside the project.
|
||||
expect(await resolvePathTarget("/tmp/missing-outside.log", "/repo")).toBeNull();
|
||||
expect(await resolvePathTarget("./outside.log", "/repo")).toBeNull();
|
||||
expect(await resolvePathTarget("/tmp/missing-dir", "/repo")).toBeNull();
|
||||
expect(mocks.findFiles).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("resolves git diff a/ and b/ prefixes and unique project filenames via findFiles", async () => {
|
||||
mocks.entryKinds.set("/repo/src/App.tsx", "file");
|
||||
expect(await resolvePathTarget("b/src/App.tsx", "/repo")).toEqual({ kind: "file", path: "/repo/src/App.tsx" });
|
||||
|
||||
mocks.findFiles.mockResolvedValueOnce([
|
||||
{ path: "/repo/src/features/terminal/TerminalView.tsx", relPath: "src/features/terminal/TerminalView.tsx" },
|
||||
]);
|
||||
expect(await resolvePathTarget("TerminalView.tsx", "/repo")).toEqual({
|
||||
kind: "file",
|
||||
path: "/repo/src/features/terminal/TerminalView.tsx",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("openPathTarget", () => {
|
||||
afterEach(() => vi.clearAllMocks());
|
||||
|
||||
it("opens both in-project and out-of-project files in the current window's editor", async () => {
|
||||
await openPathTarget({ kind: "file", path: "/repo/src/App.tsx" });
|
||||
expect(mocks.openFile).toHaveBeenCalledWith("/repo/src/App.tsx", { focus: true });
|
||||
|
||||
await openPathTarget({ kind: "file", path: "/tmp/outside.log" });
|
||||
expect(mocks.openFile).toHaveBeenCalledWith("/tmp/outside.log", { focus: true });
|
||||
});
|
||||
|
||||
it("routes folders through navigate.selectIn (expand + revealOutside) and falls back to OS file manager", async () => {
|
||||
const selectIn = vi.fn();
|
||||
const dispose = registerActions([{ id: "navigate.selectIn", title: "Select In", run: ({ arg }) => selectIn(arg) }]);
|
||||
try {
|
||||
await openPathTarget({ kind: "dir", path: "/repo/src" });
|
||||
expect(selectIn).toHaveBeenCalledWith({ path: "/repo/src", expand: true, revealOutside: true });
|
||||
expect(mocks.revealInFileManager).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
dispose();
|
||||
}
|
||||
|
||||
await openPathTarget({ kind: "dir", path: "/tmp/outside-dir" });
|
||||
expect(mocks.revealInFileManager).toHaveBeenCalledWith("/tmp/outside-dir");
|
||||
});
|
||||
});
|
||||
|
||||
describe("installModifierPathLinks — hover & click interactions", () => {
|
||||
const terms: Terminal[] = [];
|
||||
const created: Array<{ options: IDecorationOptions; decoration: IDecoration }> = [];
|
||||
const prevOs = usePlatform.getState().os;
|
||||
|
||||
beforeEach(() => {
|
||||
usePlatform.setState({ os: "macos" });
|
||||
useProject.setState({ project: { root: "/repo" } as never });
|
||||
mocks.highlightHyperlinks = true;
|
||||
mocks.entryKinds.clear();
|
||||
mocks.findFiles.mockReset().mockResolvedValue([]);
|
||||
created.length = 0;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
while (terms.length) terms.pop()!.dispose();
|
||||
document.body.replaceChildren();
|
||||
usePlatform.setState({ os: prevOs });
|
||||
useProject.setState({ project: null, settings: null });
|
||||
});
|
||||
|
||||
function setupTerm(cols = 60, rows = 4) {
|
||||
window.matchMedia ??= (() =>
|
||||
({
|
||||
matches: false,
|
||||
addListener() {},
|
||||
removeListener() {},
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
}) as unknown as MediaQueryList) as typeof window.matchMedia;
|
||||
const host = document.createElement("div");
|
||||
document.body.appendChild(host);
|
||||
const term = new Terminal({ allowProposedApi: true, cols, rows, scrollback: 100 });
|
||||
term.open(host);
|
||||
const screen = term.element!.querySelector<HTMLElement>(".xterm-screen")!;
|
||||
vi.spyOn(screen, "getBoundingClientRect").mockReturnValue(new DOMRect(0, 0, cols * 10, rows * 20));
|
||||
const register = term.registerDecoration.bind(term);
|
||||
term.registerDecoration = (options) => {
|
||||
const decoration = register(options);
|
||||
if (decoration) created.push({ options, decoration });
|
||||
return decoration;
|
||||
};
|
||||
const controller = installModifierPathLinks(term, host, {
|
||||
cwd: () => "/repo",
|
||||
color: () => "#3574f0",
|
||||
});
|
||||
terms.push(term);
|
||||
return { term, host, controller };
|
||||
}
|
||||
|
||||
const liveDecorations = () =>
|
||||
created
|
||||
.filter((d) => !d.decoration.isDisposed)
|
||||
.map(({ options: o }) => ({ x: o.x, width: o.width, fg: o.foregroundColor }));
|
||||
|
||||
it("ignores plain hover/click, activates on ⌘ while stationary, and ignores non-existent targets", async () => {
|
||||
mocks.entryKinds.set("/repo/App.tsx", "file");
|
||||
mocks.entryKinds.set("/repo/src", "dir");
|
||||
const { term, host, controller } = setupTerm();
|
||||
await write(term, "App.tsx missing.ts src");
|
||||
|
||||
// 1) Plain hover over App.tsx (col 2 => x = 25, y = 10): zero IPC, no decoration.
|
||||
host.dispatchEvent(new MouseEvent("mousemove", { bubbles: true, clientX: 25, clientY: 10 }));
|
||||
expect(commands.fsEntryKind).not.toHaveBeenCalled();
|
||||
expect(liveDecorations()).toEqual([]);
|
||||
expect(term.element).not.toHaveClass(PATH_HOVER_CLASS);
|
||||
|
||||
// 2) Press ⌘ while already hovering App.tsx (no mouse movement): becomes a hyperlink!
|
||||
window.dispatchEvent(new KeyboardEvent("keydown", { key: "Meta", metaKey: true, bubbles: true }));
|
||||
await vi.waitFor(() => expect(liveDecorations()).toEqual([{ x: 0, width: 7, fg: "#3574f0" }]));
|
||||
expect(term.element).toHaveClass(PATH_HOVER_CLASS);
|
||||
|
||||
// 3) Move with ⌘ held onto non-existent `missing.ts` (cols 9..18 => x = 125): no link!
|
||||
host.dispatchEvent(new MouseEvent("mousemove", { bubbles: true, clientX: 125, clientY: 10, metaKey: true }));
|
||||
await vi.waitFor(() => expect(commands.fsEntryKind).toHaveBeenCalledWith("/repo/missing.ts"));
|
||||
expect(liveDecorations()).toEqual([]);
|
||||
expect(term.element).not.toHaveClass(PATH_HOVER_CLASS);
|
||||
|
||||
// Clicking non-existent `missing.ts` with ⌘ opens nothing and never leaves a dangling mousedown selection.
|
||||
host.dispatchEvent(
|
||||
new MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 125, clientY: 10, metaKey: true }),
|
||||
);
|
||||
host.dispatchEvent(
|
||||
new MouseEvent("mouseup", { bubbles: true, button: 0, clientX: 125, clientY: 10, metaKey: true }),
|
||||
);
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
expect(mocks.openFile).not.toHaveBeenCalled();
|
||||
expect(term.hasSelection()).toBe(false);
|
||||
|
||||
// 4) Move onto existing `src` (cols 21..23 => x = 215) with ⌘ held, then release ⌘.
|
||||
host.dispatchEvent(new MouseEvent("mousemove", { bubbles: true, clientX: 215, clientY: 10, metaKey: true }));
|
||||
await vi.waitFor(() => expect(liveDecorations()).toEqual([{ x: 21, width: 3, fg: "#3574f0" }]));
|
||||
window.dispatchEvent(new KeyboardEvent("keyup", { key: "Meta", metaKey: false, bubbles: true }));
|
||||
expect(liveDecorations()).toEqual([]);
|
||||
expect(term.element).not.toHaveClass(PATH_HOVER_CLASS);
|
||||
|
||||
// 5) Re-press ⌘ and click `App.tsx`: opens in editor!
|
||||
host.dispatchEvent(new MouseEvent("mousemove", { bubbles: true, clientX: 25, clientY: 10, metaKey: true }));
|
||||
await vi.waitFor(() => expect(liveDecorations()).toHaveLength(1));
|
||||
host.dispatchEvent(
|
||||
new MouseEvent("mousedown", { bubbles: true, button: 0, clientX: 25, clientY: 10, metaKey: true }),
|
||||
);
|
||||
host.dispatchEvent(
|
||||
new MouseEvent("mouseup", { bubbles: true, button: 0, clientX: 25, clientY: 10, metaKey: true }),
|
||||
);
|
||||
await vi.waitFor(() => expect(mocks.openFile).toHaveBeenCalledWith("/repo/App.tsx", { focus: true }));
|
||||
|
||||
controller.dispose();
|
||||
});
|
||||
|
||||
it("invalidates its probe cache when new terminal output arrives (e.g. after creating a file)", async () => {
|
||||
const { term, host, controller } = setupTerm();
|
||||
await write(term, "fresh.txt");
|
||||
|
||||
host.dispatchEvent(new MouseEvent("mousemove", { bubbles: true, clientX: 15, clientY: 10, metaKey: true }));
|
||||
await vi.waitFor(() => expect(commands.fsEntryKind).toHaveBeenCalledTimes(1));
|
||||
expect(liveDecorations()).toEqual([]);
|
||||
|
||||
// File is created and new output arrives in the terminal.
|
||||
mocks.entryKinds.set("/repo/fresh.txt", "file");
|
||||
await write(term, "\r\nfresh.txt");
|
||||
host.dispatchEvent(new MouseEvent("mousemove", { bubbles: true, clientX: 15, clientY: 30, metaKey: true }));
|
||||
await vi.waitFor(() => expect(liveDecorations()).toEqual([{ x: 0, width: 9, fg: "#3574f0" }]));
|
||||
|
||||
controller.dispose();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,547 @@
|
||||
/**
|
||||
* Modifier-gated (`⌘` on macOS, `Ctrl` on Windows/Linux) hover hyperlinks for
|
||||
* bare file and folder names in terminal output (`ls`, `git status`, `rg`, paths):
|
||||
*
|
||||
* - Idle movement without the modifier does zero filesystem I/O and leaves mouse
|
||||
* selection and word double-click untouched.
|
||||
* - Holding `⌘`/`Ctrl` over a token probes only that token (cached per cwd and
|
||||
* invalidated on new terminal output), tinting and underlining it only when the
|
||||
* target actually exists on disk.
|
||||
* - Clicking opens files in an editor tab of the current window, and opens
|
||||
* in-project folders in the Project view (or reveals out-of-project folders in
|
||||
* the OS file manager).
|
||||
*/
|
||||
import type { IDecoration, IDisposable, IMarker, Terminal } from "@xterm/xterm";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { revealInFileManager } from "@/platform/fileManager";
|
||||
import { call, commands, isTauri } from "@/platform/ipc";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { isRemoteWindow } from "@/platform/remote";
|
||||
import { workflowSettings } from "@/platform/workflowSettings";
|
||||
import { editorService } from "@/workbench/contributions";
|
||||
import { LINK_DECORATION_CLASS, linkCells } from "./linkHighlights";
|
||||
import { findPathCandidates, normalizeCandidatePath, resolvePath, type PathCandidate } from "./links";
|
||||
|
||||
export const PATH_LINK_DECORATION_CLASS = "openidea-terminal-path-link";
|
||||
export const PATH_HOVER_CLASS = "openidea-terminal-path-hover";
|
||||
|
||||
const CACHE_TTL_MS = 2_000;
|
||||
|
||||
export interface ResolvedPathTarget {
|
||||
kind: "file" | "dir";
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface ResolvePathOptions {
|
||||
projectRoot?: string | null;
|
||||
home?: string | null;
|
||||
}
|
||||
|
||||
let cachedHome: Promise<string | null> | null = null;
|
||||
|
||||
function resolveLocalHome(): Promise<string | null> {
|
||||
if (!isTauri() || isRemoteWindow()) return Promise.resolve(null);
|
||||
return (cachedHome ??= import("@tauri-apps/api/path")
|
||||
.then(({ homeDir }) => homeDir())
|
||||
.then((h) => h.replace(/[\\/]+$/, "") || null)
|
||||
.catch(() => {
|
||||
cachedHome = null;
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
export function _resetPathLinksHomeForTests() {
|
||||
cachedHome = null;
|
||||
}
|
||||
|
||||
/** `⌘` on macOS, `Ctrl` on Windows and Linux (with no competing modifiers). */
|
||||
export function isPathLinkModifier(
|
||||
e: Pick<MouseEvent | KeyboardEvent, "metaKey" | "ctrlKey" | "altKey">,
|
||||
os = usePlatform.getState().os,
|
||||
): boolean {
|
||||
if (e.altKey) return false;
|
||||
return os === "macos" ? e.metaKey && !e.ctrlKey : e.ctrlKey && !e.metaKey;
|
||||
}
|
||||
|
||||
async function statKind(path: string): Promise<"file" | "dir" | null> {
|
||||
try {
|
||||
const kind = await call(commands.fsEntryKind(path));
|
||||
return kind === "dir" ? "dir" : kind === "file" ? "file" : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function isExplicitPath(cleaned: string): boolean {
|
||||
return (
|
||||
cleaned.startsWith("/") ||
|
||||
cleaned.startsWith("\\") ||
|
||||
cleaned === "~" ||
|
||||
cleaned.startsWith("~/") ||
|
||||
cleaned.startsWith("~\\") ||
|
||||
cleaned.startsWith("./") ||
|
||||
cleaned.startsWith("../") ||
|
||||
cleaned.startsWith(".\\") ||
|
||||
cleaned.startsWith("..\\") ||
|
||||
/^[A-Za-z]:[\\/]/.test(cleaned)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a terminal path candidate against `cwd` (then `projectRoot` and, for
|
||||
* implicit file paths with a slash or extension, `findFiles`), returning `null`
|
||||
* when the target does not exist.
|
||||
*/
|
||||
export async function resolvePathTarget(
|
||||
rawPath: string,
|
||||
cwd: string,
|
||||
opts: ResolvePathOptions = {},
|
||||
): Promise<ResolvedPathTarget | null> {
|
||||
const trailingSlash =
|
||||
/[\\/]$/.test(rawPath) && rawPath !== "/" && rawPath !== "\\" && !/^[A-Za-z]:[\\/]$/.test(rawPath);
|
||||
const cleaned = normalizeCandidatePath(rawPath);
|
||||
if (!cleaned) return null;
|
||||
|
||||
let home: string | null | undefined = opts.home;
|
||||
if (home === undefined && (cleaned === "~" || cleaned.startsWith("~/") || cleaned.startsWith("~\\"))) {
|
||||
home = await resolveLocalHome();
|
||||
if (!home) return null;
|
||||
}
|
||||
|
||||
const checkAt = async (candidate: string, base: string): Promise<ResolvedPathTarget | null> => {
|
||||
const resolved = resolvePath(candidate, base, home);
|
||||
const kind = await statKind(resolved);
|
||||
if (kind === "dir") return { kind: "dir", path: resolved };
|
||||
if (kind === "file" && !trailingSlash) return { kind: "file", path: resolved };
|
||||
return null;
|
||||
};
|
||||
|
||||
const primary = await checkAt(cleaned, cwd);
|
||||
if (primary) return primary;
|
||||
|
||||
if (isExplicitPath(cleaned)) return null;
|
||||
|
||||
const root = opts.projectRoot !== undefined ? opts.projectRoot : (useProject.getState().project?.root ?? null);
|
||||
if (root && resolvePath(cleaned, root, home) !== resolvePath(cleaned, cwd, home)) {
|
||||
const inRoot = await checkAt(cleaned, root);
|
||||
if (inRoot) return inRoot;
|
||||
}
|
||||
|
||||
// `git diff` headers (`a/src/App.tsx`, `b/src/features/`).
|
||||
if (/^[ab][\\/].+/.test(cleaned)) {
|
||||
const stripped = cleaned.slice(2);
|
||||
const fromCwd = await checkAt(stripped, cwd);
|
||||
if (fromCwd) return fromCwd;
|
||||
if (root && resolvePath(stripped, root, home) !== resolvePath(stripped, cwd, home)) {
|
||||
const fromRoot = await checkAt(stripped, root);
|
||||
if (fromRoot) return fromRoot;
|
||||
}
|
||||
}
|
||||
|
||||
if (!trailingSlash && root && (/[/\\]/.test(cleaned) || /^[^.][^/\\]*\.[A-Za-z][\w]{0,9}$/.test(cleaned))) {
|
||||
const rel = cleaned.replace(/\\/g, "/");
|
||||
try {
|
||||
const hits = await call(commands.findFiles(rel, 5));
|
||||
const hit = hits.find((h) => h.relPath === rel || h.relPath.endsWith(`/${rel}`));
|
||||
if (hit) return { kind: "file", path: hit.path };
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a resolved terminal path target: files open in an editor tab of this
|
||||
* window; folders inside the project expand and select in the Project view, and
|
||||
* folders outside the project reveal in the OS file manager.
|
||||
*/
|
||||
export async function openPathTarget(target: ResolvedPathTarget): Promise<void> {
|
||||
if (target.kind === "file") {
|
||||
await editorService().openFile(target.path, { focus: true });
|
||||
return;
|
||||
}
|
||||
const handled = await executeAction("navigate.selectIn", {
|
||||
path: target.path,
|
||||
expand: true,
|
||||
revealOutside: true,
|
||||
});
|
||||
if (!handled) await revealInFileManager(target.path);
|
||||
}
|
||||
|
||||
interface CellHit {
|
||||
col: number;
|
||||
viewRow: number;
|
||||
bufferRow: number;
|
||||
cellWidth: number;
|
||||
cellHeight: number;
|
||||
}
|
||||
|
||||
function cellFromClientPoint(term: Terminal, clientX: number, clientY: number): CellHit | null {
|
||||
const screen = term.element?.querySelector<HTMLElement>(".xterm-screen");
|
||||
if (!screen || term.cols <= 0 || term.rows <= 0) return null;
|
||||
const rect = screen.getBoundingClientRect();
|
||||
if (rect.width <= 0 || rect.height <= 0) return null;
|
||||
if (clientX < rect.left || clientX >= rect.right || clientY < rect.top || clientY >= rect.bottom) return null;
|
||||
const col = Math.floor(((clientX - rect.left) / rect.width) * term.cols);
|
||||
const viewRow = Math.floor(((clientY - rect.top) / rect.height) * term.rows);
|
||||
if (col < 0 || col >= term.cols || viewRow < 0 || viewRow >= term.rows) return null;
|
||||
return {
|
||||
col,
|
||||
viewRow,
|
||||
bufferRow: term.buffer.active.viewportY + viewRow,
|
||||
cellWidth: rect.width / term.cols,
|
||||
cellHeight: rect.height / term.rows,
|
||||
};
|
||||
}
|
||||
|
||||
interface RowCandidateMatch {
|
||||
candidate: PathCandidate;
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
function candidatesAtCell(term: Terminal, bufferRow: number, col: number): RowCandidateMatch[] {
|
||||
const line = term.buffer.active.getLine(bufferRow);
|
||||
if (!line) return [];
|
||||
const text = line.translateToString(true);
|
||||
if (!text) return [];
|
||||
return findPathCandidates(text)
|
||||
.map((candidate) => ({ candidate, ...linkCells(line, candidate) }))
|
||||
.filter((m) => m.end > m.start && col >= m.start && col < m.end);
|
||||
}
|
||||
|
||||
export interface ModifierPathLinksController extends IDisposable {
|
||||
refresh(): void;
|
||||
clearCache(): void;
|
||||
}
|
||||
|
||||
export function installModifierPathLinks(
|
||||
term: Terminal,
|
||||
host: HTMLElement,
|
||||
opts: { cwd: () => string; color: () => string },
|
||||
): ModifierPathLinksController {
|
||||
const cache = new Map<
|
||||
string,
|
||||
{
|
||||
expiresAt: number;
|
||||
settled: boolean;
|
||||
value: ResolvedPathTarget | null;
|
||||
promise: Promise<ResolvedPathTarget | null>;
|
||||
}
|
||||
>();
|
||||
let disposed = false;
|
||||
let pointer: { x: number; y: number } | null = null;
|
||||
let modifierHeld = false;
|
||||
let hoverSeq = 0;
|
||||
let downPoint: { x: number; y: number } | null = null;
|
||||
let suppressClick = false;
|
||||
let altUnderline: HTMLDivElement | null = null;
|
||||
let active: {
|
||||
bufferRow: number;
|
||||
viewRow: number;
|
||||
startCol: number;
|
||||
endCol: number;
|
||||
target: ResolvedPathTarget;
|
||||
marker?: IMarker;
|
||||
decoration?: IDecoration;
|
||||
} | null = null;
|
||||
|
||||
const cacheKey = (rawPath: string) => {
|
||||
const cwd = opts.cwd();
|
||||
const root = useProject.getState().project?.root ?? "";
|
||||
return { cwd, key: `${cwd}\0${root}\0${rawPath}` };
|
||||
};
|
||||
|
||||
const peekCached = (rawPath: string): { hit: boolean; value: ResolvedPathTarget | null } => {
|
||||
const entry = cache.get(cacheKey(rawPath).key);
|
||||
if (!entry || entry.expiresAt <= Date.now() || !entry.settled) return { hit: false, value: null };
|
||||
return { hit: true, value: entry.value };
|
||||
};
|
||||
|
||||
const probe = (rawPath: string): Promise<ResolvedPathTarget | null> => {
|
||||
const { cwd, key } = cacheKey(rawPath);
|
||||
const now = Date.now();
|
||||
const hit = cache.get(key);
|
||||
if (hit && hit.expiresAt > now) return hit.promise;
|
||||
const entry = {
|
||||
expiresAt: now + CACHE_TTL_MS,
|
||||
settled: false,
|
||||
value: null as ResolvedPathTarget | null,
|
||||
promise: Promise.resolve<ResolvedPathTarget | null>(null),
|
||||
};
|
||||
entry.promise = resolvePathTarget(rawPath, cwd).then((res) => {
|
||||
entry.settled = true;
|
||||
entry.value = res;
|
||||
return res;
|
||||
});
|
||||
cache.set(key, entry);
|
||||
return entry.promise;
|
||||
};
|
||||
|
||||
const disposeDecoration = () => {
|
||||
if (active) {
|
||||
active.decoration?.dispose();
|
||||
active.marker?.dispose();
|
||||
active = null;
|
||||
}
|
||||
if (altUnderline) altUnderline.style.display = "none";
|
||||
term.element?.classList.remove(PATH_HOVER_CLASS);
|
||||
};
|
||||
|
||||
const clearHover = () => {
|
||||
hoverSeq++;
|
||||
disposeDecoration();
|
||||
};
|
||||
|
||||
const showDecoration = (cell: CellHit, startCol: number, endCol: number, target: ResolvedPathTarget) => {
|
||||
if (
|
||||
active &&
|
||||
active.bufferRow === cell.bufferRow &&
|
||||
active.startCol === startCol &&
|
||||
active.endCol === endCol &&
|
||||
active.target.kind === target.kind &&
|
||||
active.target.path === target.path &&
|
||||
!active.marker?.isDisposed
|
||||
) {
|
||||
return;
|
||||
}
|
||||
disposeDecoration();
|
||||
term.element?.classList.add(PATH_HOVER_CLASS);
|
||||
const buf = term.buffer.active;
|
||||
if (buf.type === "normal") {
|
||||
const marker = term.registerMarker(cell.bufferRow - (buf.baseY + buf.cursorY));
|
||||
if (marker) {
|
||||
const decoration = term.registerDecoration({
|
||||
marker,
|
||||
x: startCol,
|
||||
width: endCol - startCol,
|
||||
foregroundColor: opts.color(),
|
||||
});
|
||||
if (decoration) {
|
||||
decoration.onRender((el) => el.classList.add(LINK_DECORATION_CLASS, PATH_LINK_DECORATION_CLASS));
|
||||
active = { bufferRow: cell.bufferRow, viewRow: cell.viewRow, startCol, endCol, target, marker, decoration };
|
||||
return;
|
||||
}
|
||||
marker.dispose();
|
||||
}
|
||||
}
|
||||
const screen = term.element?.querySelector<HTMLElement>(".xterm-screen");
|
||||
if (screen) {
|
||||
if (!altUnderline || !altUnderline.isConnected) {
|
||||
altUnderline = document.createElement("div");
|
||||
altUnderline.className = `xterm-decoration ${LINK_DECORATION_CLASS} ${PATH_LINK_DECORATION_CLASS}`;
|
||||
altUnderline.setAttribute("aria-hidden", "true");
|
||||
altUnderline.style.position = "absolute";
|
||||
screen.appendChild(altUnderline);
|
||||
}
|
||||
Object.assign(altUnderline.style, {
|
||||
display: "block",
|
||||
left: `${startCol * cell.cellWidth}px`,
|
||||
top: `${cell.viewRow * cell.cellHeight}px`,
|
||||
width: `${(endCol - startCol) * cell.cellWidth}px`,
|
||||
height: `${cell.cellHeight}px`,
|
||||
});
|
||||
}
|
||||
active = { bufferRow: cell.bufferRow, viewRow: cell.viewRow, startCol, endCol, target };
|
||||
};
|
||||
|
||||
const evaluateAt = async (x: number, y: number) => {
|
||||
if (disposed || !workflowSettings().terminal.highlightHyperlinks || !modifierHeld) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
const cell = cellFromClientPoint(term, x, y);
|
||||
if (!cell) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
if (
|
||||
active &&
|
||||
active.bufferRow === cell.bufferRow &&
|
||||
cell.col >= active.startCol &&
|
||||
cell.col < active.endCol &&
|
||||
!active.marker?.isDisposed
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const matches = candidatesAtCell(term, cell.bufferRow, cell.col);
|
||||
if (!matches.length) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
const seq = ++hoverSeq;
|
||||
disposeDecoration();
|
||||
for (const match of matches) {
|
||||
// oxlint-disable-next-line no-await-in-loop -- outer quoted path takes precedence; probe inner token only if outer misses
|
||||
const target = await probe(match.candidate.path);
|
||||
if (disposed || seq !== hoverSeq || !modifierHeld) return;
|
||||
if (target) {
|
||||
const now = pointer ? cellFromClientPoint(term, pointer.x, pointer.y) : null;
|
||||
if (now && now.bufferRow === cell.bufferRow && now.col >= match.start && now.col < match.end) {
|
||||
showDecoration(now, match.start, match.end, target);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
clearHover();
|
||||
};
|
||||
|
||||
const onMouseMove = (e: MouseEvent) => {
|
||||
pointer = { x: e.clientX, y: e.clientY };
|
||||
modifierHeld = isPathLinkModifier(e);
|
||||
if (modifierHeld) void evaluateAt(e.clientX, e.clientY);
|
||||
else if (active) clearHover();
|
||||
};
|
||||
|
||||
const onMouseLeave = () => {
|
||||
pointer = null;
|
||||
downPoint = null;
|
||||
clearHover();
|
||||
};
|
||||
|
||||
const onMouseDown = (e: MouseEvent) => {
|
||||
if (e.button !== 0 || !workflowSettings().terminal.highlightHyperlinks || !isPathLinkModifier(e)) {
|
||||
downPoint = null;
|
||||
return;
|
||||
}
|
||||
const cell = cellFromClientPoint(term, e.clientX, e.clientY);
|
||||
if (!cell) {
|
||||
downPoint = null;
|
||||
return;
|
||||
}
|
||||
if (active && active.bufferRow === cell.bufferRow && cell.col >= active.startCol && cell.col < active.endCol) {
|
||||
downPoint = { x: e.clientX, y: e.clientY };
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
const matches = candidatesAtCell(term, cell.bufferRow, cell.col);
|
||||
// Only intercept an unprobed / positive candidate; known non-existent tokens pass straight to xterm.
|
||||
const couldMatch = matches.some((m) => {
|
||||
const c = peekCached(m.candidate.path);
|
||||
return !c.hit || c.value !== null;
|
||||
});
|
||||
if (!couldMatch) {
|
||||
downPoint = null;
|
||||
return;
|
||||
}
|
||||
downPoint = { x: e.clientX, y: e.clientY };
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const onMouseUp = (e: MouseEvent) => {
|
||||
const start = downPoint;
|
||||
downPoint = null;
|
||||
if (!start || e.button !== 0) return;
|
||||
// Always pair-consume `mouseup` when `mousedown` was consumed so xterm never sees a half-press.
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
suppressClick = true;
|
||||
if (!workflowSettings().terminal.highlightHyperlinks || !isPathLinkModifier(e)) return;
|
||||
if (Math.hypot(e.clientX - start.x, e.clientY - start.y) > 4) return;
|
||||
const cell = cellFromClientPoint(term, e.clientX, e.clientY);
|
||||
if (!cell) return;
|
||||
if (active && active.bufferRow === cell.bufferRow && cell.col >= active.startCol && cell.col < active.endCol) {
|
||||
const target = active.target;
|
||||
clearHover();
|
||||
void openPathTarget(target);
|
||||
return;
|
||||
}
|
||||
const matches = candidatesAtCell(term, cell.bufferRow, cell.col);
|
||||
if (!matches.length) return;
|
||||
clearHover();
|
||||
void (async () => {
|
||||
for (const match of matches) {
|
||||
// oxlint-disable-next-line no-await-in-loop -- outer quoted path takes precedence over inner token
|
||||
const target = await probe(match.candidate.path);
|
||||
if (disposed) return;
|
||||
if (target) {
|
||||
await openPathTarget(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
const onClick = (e: MouseEvent) => {
|
||||
if (!suppressClick) return;
|
||||
suppressClick = false;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const onKeyChange = (e: KeyboardEvent) => {
|
||||
const next = isPathLinkModifier(e);
|
||||
if (next === modifierHeld) return;
|
||||
modifierHeld = next;
|
||||
if (!next) clearHover();
|
||||
else if (pointer) void evaluateAt(pointer.x, pointer.y);
|
||||
};
|
||||
|
||||
const onBlur = () => {
|
||||
modifierHeld = false;
|
||||
downPoint = null;
|
||||
clearHover();
|
||||
};
|
||||
|
||||
host.addEventListener("mousemove", onMouseMove);
|
||||
host.addEventListener("mouseleave", onMouseLeave);
|
||||
host.addEventListener("mousedown", onMouseDown, true);
|
||||
host.addEventListener("mouseup", onMouseUp, true);
|
||||
host.addEventListener("click", onClick, true);
|
||||
if (typeof window !== "undefined") {
|
||||
window.addEventListener("keydown", onKeyChange, true);
|
||||
window.addEventListener("keyup", onKeyChange, true);
|
||||
window.addEventListener("blur", onBlur);
|
||||
}
|
||||
|
||||
const subs = [
|
||||
term.onWriteParsed?.(() => cache.clear()),
|
||||
term.onScroll?.(() => {
|
||||
if (modifierHeld && pointer) void evaluateAt(pointer.x, pointer.y);
|
||||
else clearHover();
|
||||
}),
|
||||
term.buffer?.onBufferChange?.(() => {
|
||||
if (modifierHeld && pointer) void evaluateAt(pointer.x, pointer.y);
|
||||
else clearHover();
|
||||
}),
|
||||
].filter((s): s is IDisposable => !!s);
|
||||
|
||||
return {
|
||||
refresh() {
|
||||
if (!workflowSettings().terminal.highlightHyperlinks) {
|
||||
clearHover();
|
||||
return;
|
||||
}
|
||||
if (active && pointer && modifierHeld) {
|
||||
disposeDecoration();
|
||||
void evaluateAt(pointer.x, pointer.y);
|
||||
}
|
||||
},
|
||||
clearCache() {
|
||||
cache.clear();
|
||||
},
|
||||
dispose() {
|
||||
disposed = true;
|
||||
clearHover();
|
||||
altUnderline?.remove();
|
||||
altUnderline = null;
|
||||
cache.clear();
|
||||
subs.forEach((s) => s.dispose());
|
||||
host.removeEventListener("mousemove", onMouseMove);
|
||||
host.removeEventListener("mouseleave", onMouseLeave);
|
||||
host.removeEventListener("mousedown", onMouseDown, true);
|
||||
host.removeEventListener("mouseup", onMouseUp, true);
|
||||
host.removeEventListener("click", onClick, true);
|
||||
if (typeof window !== "undefined") {
|
||||
window.removeEventListener("keydown", onKeyChange, true);
|
||||
window.removeEventListener("keyup", onKeyChange, true);
|
||||
window.removeEventListener("blur", onBlur);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import { installTerminalDrop } from "./drop";
|
||||
import { installDomRowCache } from "./domRowCache";
|
||||
import { installSelectionHighlights, type SelectionHighlightController } from "./highlight";
|
||||
import { installLinkHighlights, xtermLink, type LinkHighlightController } from "./linkHighlights";
|
||||
import { installModifierPathLinks, type ModifierPathLinksController } from "./pathLinks";
|
||||
import { installTerminalPaste, pasteIntoTerminal, pasteTerminalClipboard } from "./paste";
|
||||
import { ImeCommitGate } from "./imeCommit";
|
||||
import { installImeAnchor } from "./imeAnchor";
|
||||
@@ -254,6 +255,7 @@ export class TerminalSession {
|
||||
private searchSelection = false;
|
||||
private readonly selectionHighlights: SelectionHighlightController;
|
||||
private readonly linkHighlights: LinkHighlightController;
|
||||
private readonly pathLinks: ModifierPathLinksController;
|
||||
private opts: SessionOptions;
|
||||
private snapshot: SessionSnapshot;
|
||||
private ptyId: TerminalId | null = null;
|
||||
@@ -472,7 +474,11 @@ export class TerminalSession {
|
||||
isSearchSelection: () => this.searchSelection,
|
||||
});
|
||||
this.linkHighlights = installLinkHighlights(this.term, readLinkColor);
|
||||
this.disposables.push(this.selectionHighlights, this.linkHighlights);
|
||||
this.pathLinks = installModifierPathLinks(this.term, this.host, {
|
||||
cwd: () => this.snapshot.cwd,
|
||||
color: readLinkColor,
|
||||
});
|
||||
this.disposables.push(this.selectionHighlights, this.linkHighlights, this.pathLinks);
|
||||
this.disposables.push(
|
||||
{ dispose: installTerminalPaste(this.host, (text) => this.paste(text), this.clipboardTarget) },
|
||||
{ dispose: installTerminalDrop(this.host, (text) => this.paste(text), this.clipboardTarget) },
|
||||
@@ -544,6 +550,7 @@ export class TerminalSession {
|
||||
o.macOptionIsMeta = t.optionAsMeta;
|
||||
this.selectionHighlights.refresh();
|
||||
this.linkHighlights.refresh();
|
||||
this.pathLinks.refresh();
|
||||
this.scheduleFit();
|
||||
}
|
||||
|
||||
@@ -1077,6 +1084,7 @@ export class TerminalSession {
|
||||
this.term.options.theme = readTerminalTheme();
|
||||
this.searchDecorations = null;
|
||||
this.linkHighlights.refresh();
|
||||
this.pathLinks.refresh();
|
||||
}
|
||||
|
||||
/** Finds `query` (highlighting every match); `incremental` keeps the current match while typing. */
|
||||
|
||||
@@ -33,9 +33,14 @@
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* Always-on underline for highlighted URLs (linkHighlights); the decoration's foreground colour tints the text. */
|
||||
/* Always-on underline for highlighted URLs (linkHighlights) and modifier-hovered paths (pathLinks). */
|
||||
.xterm .xterm-decoration.openidea-terminal-link {
|
||||
box-sizing: border-box;
|
||||
border-bottom: 1px solid var(--link, var(--accent));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.xterm.openidea-terminal-path-hover,
|
||||
.xterm.openidea-terminal-path-hover.enable-mouse-events {
|
||||
cursor: pointer;
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача