Файли
openidea/src/features/project-tree/filePath.ts
T
l0ng-ai 0c9c51b0f5 feat(editor): Add folding, navigation, editing and window shortcuts (#153)
Editing and folding
- Move Caret to Code Block Start / End with Selection, Auto-Indent Lines,
  Move Element Left / Right (swaps call arguments, parameters and list
  entries).
- Fold Code Block folds the {...} block around the caret; Expand to Level
  and Expand All to Level 1-5.
- Custom folding regions (//region, #region, <editor-fold>) fold to their
  description; Navigate > Custom Folding lists them.
- Error Description shows the problems at the caret; Next / Previous
  Highlighted Usage steps through usage highlights.
- Editor tooltips stay below the editor's top edge, so hints on the first
  lines no longer hide under the tab bar.

Navigation, project and run
- Navigate > File Path lists the file and its folders to reveal in the file
  manager.
- Copy... (F5) opens the Copy dialog for the selection or the open file; the
  project view's Refactor submenu gets Copy File.
- Debug... chooses a configuration to debug; Quick Evaluate Expression shows
  the selection's value in an expandable hint.
- Inspect Current File runs the inspection without the scope dialog.
- Surround with Live Template lists only $SELECTION$ templates; Java gets
  Callable, read / write lock and iterate templates.

Windows
- Stretch the active tool window left / right / up / down, Restore Default
  Layout, Go to Next / Previous Splitter, Close Active Tab on a second key,
  Stop Background Processes.

All actions have default shortcuts in both keymaps, VS Code preset entries,
main menu items and Chinese translations.

Project view and Keymap settings
- Project view Options: Sort by Name / Type / Modification Time (also in
  Find Action).
- Settings > Keymap: Add Mouse Shortcut records a side-button click with
  modifiers and checks conflicts like keyboard shortcuts.
- Folding: Expand to Level / Expand All to Level 1-5.
2026-10-29 00:39:37 +08:00

46 рядки
1.5 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/** Navigate › File Path (⌥⌘F12): the file and its folders, each revealed in the OS file manager. */
import { openPopup } from "@/editor/lsp/popupStore";
import { notifications } from "@/workbench/contributions";
import { tx } from "@/platform/i18n";
import { nameOf, parentOf } from "./paths";
import { revealLabel } from "./contextMenu";
const DRIVE_ROOT = /^[A-Za-z]:\/?$/;
/** `path` then each folder above it, up to the file system (or drive) root. */
export function filePathChain(path: string): string[] {
const out = [path];
for (let p = path; p !== "/" && !DRIVE_ROOT.test(p);) {
const parent = parentOf(p);
if (parent === p) break;
p = /^[A-Za-z]:$/.test(parent) ? `${parent}/` : parent;
out.push(p);
}
return out;
}
async function reveal(path: string) {
try {
const { revealItemInDir } = await import("@tauri-apps/plugin-opener");
await revealItemInDir(path);
} catch (e) {
const fileManager = revealLabel();
notifications().notify({
level: "error",
title: tx`Cannot reveal in ${fileManager}`,
body: e instanceof Error ? e.message : String(e),
});
}
}
export function showFilePathPopup(path: string, isDir = false) {
const items = filePathChain(path).map((p, i) => ({
id: p,
label: nameOf(p) || p,
detail: i === 0 ? undefined : p,
icon: i === 0 && !isDir ? "file" : "folder",
run: () => reveal(p),
}));
openPopup({ kind: "list", anchor: { x: window.innerWidth / 2 - 160, y: 96 }, title: "File Path", items });
}