Файли
openidea/src/features/project-tree/newPopupModel.ts
T
l0ng-ai 1e00ea5ee2 feat: Third pass aligning core experience with IntelliJ IDEA
Project & files
- Project view modes (Project Files / Open Files / All Changed Files /
  Scratches); External Libraries for Python, JDK (src.zip), Node, Cargo, Go,
  Maven/Gradle jars; read-only jar/zip browsing
- ⌘N New popup with type search and more file kinds; New Project, Rename
  Project, Reload All from Disk, Export/Import Settings, Power Save Mode
- File type associations, extra content roots and exclude patterns (indexed
  and watched without reopening the project)

Editor & navigation
- Find bar: search scope (comments/strings), Preserve Case, Exclude, multiline,
  history; Find in Files: Module scope, custom pattern scopes, multiline
- Search Everywhere filters, Assign Shortcut, settings results; named bookmark
  lists, file/folder bookmarks; Structure filters and Show Inherited; Recent
  Locations timestamps and breadcrumbs; Code Vision author
- Completion options, editor tab placement/layout, inline completion (LSP 3.18)
- Spell checking (Typo inspection, ide-spell) and Inspections settings with
  custom profiles; Code Style schemes, formatter markers, Do not format

Run, VCS, services, database
- Typed run configurations (Shell, Program, npm, Gradle, Maven, Docker,
  Compound), Modify options, Before launch, env dialog, Current File,
  Emulate terminal (PTY)
- Git log graph/view options, Go to Hash/Branch/Tag, date filter keeps the
  graph; Pull/Merge/Rebase dialogs, Manage Remotes, Worktrees
- Generic Services host (Docker connections/registries, run sessions); TODO
  scope/changes tabs with changelists; Coverage report import
- Data sources: wire-compatible vendors, URL import, SSL certs, Options,
  Schemas and Advanced tabs, color and comment

Workbench
- Run Anything, Customize Main Toolbar, named tool window layouts, menu
  completeness, Code Cleanup, macros, "Don't Show Again", editor banners
- Chinese translations for the new UI

Claude-Session: https://claude.ai/code/session_01SaPPsVPuk6ZTNsoUCNCbMv
2026-10-25 21:24:00 +08:00

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

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/** IDEA's "New" popup (⌘N): the New › items under a "Search for file type" field. */
import { create } from "zustand";
import { getAction } from "@/platform/actions";
import { fuzzyMatch, resolveMenuItems, type MenuItem } from "@/ui";
export interface NewPopupRow {
key: string;
separator?: boolean;
label: string;
icon?: string;
shortcut?: string;
run?: () => void;
/** Matched label indices while filtering. */
matches?: number[] | null;
}
interface NewPopupState {
request: { at: { x: number; y: number }; items: MenuItem[]; seq: number } | null;
}
export const useNewPopup = create<NewPopupState>(() => ({ request: null }));
let seq = 0;
export function openNewPopup(at: { x: number; y: number }, items: MenuItem[]) {
useNewPopup.setState({ request: { at, items, seq: ++seq } });
}
export const closeNewPopup = () => useNewPopup.setState({ request: null });
/** Generic action keywords that would match every template. */
const GENERIC = new Set(["new", "create", "template", "file"]);
/**
* Enabled entries, filtered by `query`: label matches (highlighted), then
* entries whose action has a matching keyword (`css` finds Stylesheet).
* Separators are kept only without a query.
*/
export function newPopupRows(items: MenuItem[], query: string): NewPopupRow[] {
const q = query.trim();
const rows: NewPopupRow[] = [];
const byKeyword: NewPopupRow[] = [];
for (const r of resolveMenuItems(items)) {
if (r.kind === "separator") {
if (!q && rows.length && !rows[rows.length - 1]!.separator) rows.push({ key: r.key, separator: true, label: "" });
continue;
}
if (r.kind !== "item" || r.disabled || !r.run) continue;
const row: NewPopupRow = { key: r.key, label: r.label, icon: r.icon, shortcut: r.shortcut, run: r.run };
if (!q) {
rows.push(row);
continue;
}
const matches = fuzzyMatch(r.label, q);
if (matches) rows.push({ ...row, matches });
else if (keywordMatch(r.key, q)) byKeyword.push(row);
}
while (rows.length && rows[rows.length - 1]!.separator) rows.pop();
return [...rows, ...byKeyword];
}
function keywordMatch(actionId: string, q: string): boolean {
const lower = q.toLowerCase().replace(/^\./, "");
return !!getAction(actionId)?.keywords?.some(
(k) => !GENERIC.has(k) && k.toLowerCase().replace(/^\./, "").startsWith(lower),
);
}