дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
Whole-line copies and cuts paste above the caret line from every paste entry point (shortcut, menu, history, plain text), including a copied blank line. Paste from History opens a dialog with filter, multi-select, delete and preview. Copy Path/Reference (⇧⌘C) opens a chooser for absolute path, file name, content-root/source-root paths, path with line and reference. Text pasted into a string literal is escaped (Smart Keys setting; Paste as Plain Text bypasses it), and missing imports are added after a paste (Auto Import setting: Ask / Always / Never).
24 рядки
975 B
TypeScript
24 рядки
975 B
TypeScript
import { isSameOrInside } from "./paths";
|
|
import { basename, projectFolder, useProject } from "./project";
|
|
import { projectRelative, rootOfPath } from "./projectRoots";
|
|
|
|
export type PathKind = "absolute" | "relative" | "name" | "source";
|
|
|
|
/** Shared by the project view, editor tabs and the caret's copy chooser. */
|
|
export function pathToCopy(
|
|
kind: PathKind,
|
|
path: string,
|
|
root: string | null = projectFolder(useProject.getState().project, path)?.root ?? null,
|
|
): string | null {
|
|
if (kind === "absolute") return path;
|
|
if (kind === "name") return basename(path);
|
|
if (kind === "source") {
|
|
const source = rootOfPath(path);
|
|
const relative = projectRelative(path);
|
|
if (!source || source.kind === "excluded" || relative === null) return null;
|
|
return relative.slice(source.path.length + (source.path ? 1 : 0)) || ".";
|
|
}
|
|
if (!root || !isSameOrInside(path, root)) return path;
|
|
return path.slice(root.length + (root.endsWith("/") ? 0 : 1)) || ".";
|
|
}
|