дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
Порівняти коміти
17
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
1e8138fa25 | ||
|
|
e2ca1ca4e0 | ||
|
|
b02f212d3e | ||
|
|
ca7f26f484 | ||
|
|
bf4fff8fcf | ||
|
|
3cbe327a6a | ||
|
|
0311297886 | ||
|
|
a711c991b6 | ||
|
|
698cad2b3f | ||
|
|
581c64f544 | ||
|
|
77d6d81f8a | ||
|
|
ea62941bc6 | ||
|
|
00e044b66b | ||
|
|
1db368d2b4 | ||
|
|
db50b5df5b | ||
|
|
17fe162f6c | ||
|
|
0fc462350b |
No files matched your search
@@ -28,6 +28,8 @@ on:
|
||||
- "src/workbench/**"
|
||||
- "src/ui/**"
|
||||
- "src/editor/api.ts"
|
||||
- "src/editor/navigationProviders.ts"
|
||||
- "src/editor/relatedProviders.ts"
|
||||
- "src/editor/core/cm/cornerInset.ts"
|
||||
- "src/editor/core/cm/iconArea.ts"
|
||||
- "src/editor/lsp/availability.ts"
|
||||
@@ -98,7 +100,7 @@ jobs:
|
||||
# ide-lsp/dap/run/sdk/tools.
|
||||
unused='^crates/(ide-agent|ide-analysis|ide-android|ide-cli|ide-clipboard|ide-coverage|ide-db|ide-docker|ide-fonts|ide-github|ide-http|ide-mcp|ide-notebook|ide-profiler|ide-scaffold|ide-spell|ide-ssh|ide-vcs|ide-web)/'
|
||||
# The workflow's paths, less those handled per language below.
|
||||
smoke='^(crates/|Cargo\.(toml|lock)$|src/features/(run|debugger|build-tools)/|src/platform/|src/workbench/|src/ui/|src/editor/(api|core/cm/(cornerInset|iconArea)|lsp/(availability|diagnostics|files|hint|lsp|positions))\.ts$|src/bindings\.ts$|src/styles/tokens\.css$|src/test/setup\.ts$|src-tauri/icons/128x128\.png$|smoke/|vite\.config\.ts$|tsconfig\.json$|package\.json$|pnpm-(lock|workspace)\.yaml$|patches/|\.github/workflows/language-smoke\.yml$|\.github/tool-versions\.env$)'
|
||||
smoke='^(crates/|Cargo\.(toml|lock)$|src/features/(run|debugger|build-tools)/|src/platform/|src/workbench/|src/ui/|src/editor/(api|navigationProviders|relatedProviders|core/cm/(cornerInset|iconArea)|lsp/(availability|diagnostics|files|hint|lsp|positions))\.ts$|src/bindings\.ts$|src/styles/tokens\.css$|src/test/setup\.ts$|src-tauri/icons/128x128\.png$|smoke/|vite\.config\.ts$|tsconfig\.json$|package\.json$|pnpm-(lock|workspace)\.yaml$|patches/|\.github/workflows/language-smoke\.yml$|\.github/tool-versions\.env$)'
|
||||
langs=""
|
||||
while read -r f; do
|
||||
case "$f" in
|
||||
|
||||
@@ -79,6 +79,7 @@ Shared agent skills live in `.agents/skills/` (`.claude/skills/` links to them):
|
||||
`pnpm dev:app` also enables the global Tauri API. `pnpm dev:status` reports
|
||||
this worktree's running MCP bridges and actual ports.
|
||||
- `pnpm build` — typecheck + bundle frontend.
|
||||
- `pnpm dogfood:build` / `pnpm dogfood:install` (or `mise run dogfood:build` / `mise run dogfood:install`) — build and locally install the grey-icon dogfood desktop app sharing release settings and data.
|
||||
- `cargo nextest run --workspace` (or `cargo test`), `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --all`.
|
||||
- `cargo test -p ide-host --test language_smoke -- --ignored --exact <language>` — code intelligence
|
||||
on `fixtures/` with that language's real server installed (CI: `Language smoke`, pinned versions).
|
||||
|
||||
@@ -67,7 +67,7 @@ mise run dev
|
||||
|
||||
`setup` runs `pnpm install` in this worktree. `dev` and `dev:app` use the same worktree-aware launchers as the direct commands. No shell activation is needed for `mise run`.
|
||||
|
||||
Run `mise tasks` to list all six tasks. `mise run build` builds the frontend (not a desktop installer). `mise run test` runs Vitest and `cargo test --workspace`; `mise run check` runs the format, lint, type and unused-code checks, then both test suites. Neither requires nextest or the plugin WASM target.
|
||||
Run `mise tasks` to list all tasks. `mise run build` builds the frontend (not a desktop installer); `mise run dogfood:build` and `mise run dogfood:install` build and locally install a grey-icon dogfood desktop app that shares settings and data with the release app. Only one of the two apps runs at a time, since they share one instance; settings written by the newer dogfood build can make an older release ignore the settings file. The dogfood app never updates itself: run `dogfood:install` again to pick up new changes. `mise run test` runs Vitest and `cargo test --workspace`; `mise run check` runs the format, lint, type and unused-code checks, then both test suites. Neither requires nextest or the plugin WASM target.
|
||||
|
||||
## Worktrees
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ mise run dev
|
||||
|
||||
`setup` 在当前 worktree 中执行 `pnpm install`。`dev` 和 `dev:app` 都沿用原来的启动脚本,保留 worktree 隔离。使用 `mise run` 不需要在 shell 中激活 mise。
|
||||
|
||||
运行 `mise tasks` 可以查看全部六个任务。`mise run build` 构建前端,不生成桌面安装包。`mise run test` 运行 Vitest 和 `cargo test --workspace`;`mise run check` 先检查格式、代码规范、类型和未使用的代码,再运行这两套测试。两者都不需要 nextest 或插件的 WASM 目标。
|
||||
运行 `mise tasks` 可以查看全部任务。`mise run build` 构建前端,不生成桌面安装包;`mise run dogfood:build` 和 `mise run dogfood:install` 用于构建并在本地安装灰色图标的 dogfood 桌面版(与正式版共享设置和数据)。两者共用同一个实例,同一时间只能运行一个;较新的 dogfood 版写入的设置可能让较旧的正式版忽略整个设置文件。dogfood 版不会自动更新,需要更新时重新运行 `dogfood:install`。`mise run test` 运行 Vitest 和 `cargo test --workspace`;`mise run check` 先检查格式、代码规范、类型和未使用的代码,再运行这两套测试。两者都不需要 nextest 或插件的 WASM 目标。
|
||||
|
||||
## Worktree
|
||||
|
||||
|
||||
@@ -196,6 +196,68 @@ test("long completion signatures fit the editor when the workbench is narrowed",
|
||||
await expect(editor.locator(".cm-activeLine")).toContainText(`order.${label}()`);
|
||||
});
|
||||
|
||||
test("completion clips long parameters before the suggestion name and return type", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 760 });
|
||||
const editor = await openSample(page);
|
||||
const label = "reconcilePendingOrdersByRegion";
|
||||
const returnType = "RegionalSettlementResult";
|
||||
await page.evaluate(
|
||||
({ label, returnType }) => {
|
||||
const labelDetail =
|
||||
"(pendingOrders: ReadonlyArray<PendingOrder>, reconciliationOptions: RegionalReconciliationOptions)";
|
||||
const item: CompletionItem = {
|
||||
label,
|
||||
labelDetail,
|
||||
labelDescription: returnType,
|
||||
detail: null,
|
||||
kind: "method",
|
||||
documentation: null,
|
||||
sortText: null,
|
||||
filterText: null,
|
||||
preselect: true,
|
||||
deprecated: false,
|
||||
insertText: `${label}()`,
|
||||
isSnippet: false,
|
||||
replaceRange: null,
|
||||
replaceRangeTab: null,
|
||||
additionalEdits: [],
|
||||
commitCharacters: [],
|
||||
command: null,
|
||||
data: null,
|
||||
server: 1,
|
||||
};
|
||||
window.__ipc.handlers.lsp_completion = () => ({ isIncomplete: false, items: [item] });
|
||||
},
|
||||
{ label, returnType },
|
||||
);
|
||||
await editor.locator(".cm-line", { hasText: "return order.toDto()" }).click();
|
||||
await page.keyboard.press("End");
|
||||
await page.keyboard.press("Enter");
|
||||
await page.keyboard.type("order.");
|
||||
await page.keyboard.press("Control+Space");
|
||||
|
||||
const popup = page.locator(".cm-tooltip-autocomplete");
|
||||
const row = popup.getByRole("option").filter({
|
||||
has: page.locator(".cm-completionLabel", { hasText: label }),
|
||||
});
|
||||
await expect(row.locator(".cm-lsp-type")).toHaveText(returnType);
|
||||
await page.setViewportSize({ width: 820, height: 760 });
|
||||
await expect
|
||||
.poll(() =>
|
||||
row.evaluate((el) => {
|
||||
const name = el.querySelector<HTMLElement>(".cm-completionLabel")!;
|
||||
const parameters = el.querySelector<HTMLElement>(".cm-completionDetail")!;
|
||||
const type = el.querySelector<HTMLElement>(".cm-lsp-type")!;
|
||||
return {
|
||||
nameFits: name.scrollWidth <= name.clientWidth + 1,
|
||||
typeFits: type.scrollWidth <= type.clientWidth + 1,
|
||||
parametersClipped: parameters.scrollWidth > parameters.clientWidth,
|
||||
};
|
||||
}),
|
||||
)
|
||||
.toEqual({ nameFits: true, typeFits: true, parametersClipped: true });
|
||||
});
|
||||
|
||||
test("documentation shows beside the lookup instead of being clipped by it", async ({ workbench: page }, info) => {
|
||||
const editor = await openSample(page);
|
||||
await page.evaluate(async () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ test("Copy Path/Reference keeps its preview and shortcut visible and can be resi
|
||||
await editor.locator(".cm-content").press("Meta+Shift+C");
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Copy Path/Reference…" });
|
||||
const absolute = popup.getByRole("option", { name: /^Absolute Path/ });
|
||||
const absolute = popup.getByRole("option", { name: /^Absolute Path(?! with)/ });
|
||||
const preview = absolute.locator('[title$="/build.gradle.kts"]');
|
||||
const shortcut = absolute.getByText(/⌘/);
|
||||
await expect(preview).toBeVisible();
|
||||
|
||||
@@ -299,6 +299,47 @@ test("⌘R replaces every match in the file", async ({ workbench: page }) => {
|
||||
await expect(editor.locator(".cm-line", { hasText: "OrderDto" })).toHaveCount(2);
|
||||
});
|
||||
|
||||
test("the inline find and replace fields share a column that grows with the editor", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 760 });
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
await editor.locator(".cm-content").click();
|
||||
await page.keyboard.press("Meta+r");
|
||||
const bar = page.getByRole("search", { name: "Replace in file" });
|
||||
const find = bar.getByRole("textbox", { name: "Find" });
|
||||
const replace = bar.getByRole("textbox", { name: "Replace" });
|
||||
const more = bar.getByRole("button", { name: "More", exact: true });
|
||||
const close = bar.getByRole("button", { name: "Close", exact: true });
|
||||
await find.fill("OrderDto");
|
||||
await replace.fill("OrderView");
|
||||
|
||||
const column = () =>
|
||||
bar.evaluate((panel) => {
|
||||
const [find, replace] = panel.querySelectorAll("textarea");
|
||||
const findField = find!.parentElement!.getBoundingClientRect();
|
||||
const replaceField = replace!.parentElement!.getBoundingClientRect();
|
||||
return {
|
||||
left: findField.left,
|
||||
width: findField.width,
|
||||
replaceLeft: replaceField.left,
|
||||
replaceWidth: replaceField.width,
|
||||
};
|
||||
});
|
||||
const initial = await column();
|
||||
expect(initial.left).toBeCloseTo(initial.replaceLeft);
|
||||
expect(initial.width).toBeCloseTo(initial.replaceWidth);
|
||||
|
||||
for (const width of [1120, 1480]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
const [moreBox, closeBox] = await Promise.all([more.boundingBox(), close.boundingBox()]);
|
||||
expect(closeBox!.y).toBeCloseTo(moreBox!.y);
|
||||
expect(closeBox!.x).toBeGreaterThanOrEqual(moreBox!.x + moreBox!.width);
|
||||
expect(closeBox!.x).toBeLessThanOrEqual(moreBox!.x + moreBox!.width + 4);
|
||||
}
|
||||
await expect.poll(async () => (await column()).width).toBeGreaterThan(initial.width + 60);
|
||||
await close.click();
|
||||
await expect(bar).toBeHidden();
|
||||
});
|
||||
|
||||
test("the inline find and replace controls stay inside a narrow editor pane", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 760 });
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
@@ -331,13 +372,19 @@ test("the inline find and replace controls stay inside a narrow editor pane", as
|
||||
await expect.poll(navigationIsBelowFind).toBe(true);
|
||||
await page.setViewportSize({ width: 495, height: 760 });
|
||||
await expect.poll(controlsFit).toBe(true);
|
||||
const close = bar.getByRole("button", { name: "Close", exact: true });
|
||||
const more = bar.getByRole("button", { name: "More", exact: true });
|
||||
const [moreBox, closeBox] = await Promise.all([more.boundingBox(), close.boundingBox()]);
|
||||
expect(closeBox!.y).toBeCloseTo(moreBox!.y);
|
||||
expect(closeBox!.x).toBeGreaterThanOrEqual(moreBox!.x + moreBox!.width);
|
||||
expect(closeBox!.x).toBeLessThanOrEqual(moreBox!.x + moreBox!.width + 4);
|
||||
await expect(find).toHaveValue("OrderDto");
|
||||
await expect(replace).toHaveValue("OrderView");
|
||||
await next.click();
|
||||
await expect(bar.getByText(/^[12]\/2$/)).toBeVisible();
|
||||
await bar.getByRole("button", { name: "Replace All" }).click();
|
||||
await expect(editor.locator(".cm-line", { hasText: "OrderView" })).toHaveCount(2);
|
||||
await bar.getByRole("button", { name: "Close", exact: true }).click();
|
||||
await close.click();
|
||||
await expect(bar).toBeHidden();
|
||||
});
|
||||
|
||||
|
||||
@@ -174,6 +174,74 @@ test("Git Log keeps filters and actions inside the commit pane at the minimum wi
|
||||
await expect(page.getByRole("menuitem", { name: "Paths" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Git Log puts affected changes on the changed-files toolbar and groups preview options", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1100, height: 720 });
|
||||
await page.evaluate(() => {
|
||||
window.__ipc.handlers.vcs_commit_files = () => [
|
||||
{ path: "src/prices.ts", oldPath: null, kind: "modified" },
|
||||
{ path: "docs/checkout.md", oldPath: null, kind: "modified" },
|
||||
];
|
||||
});
|
||||
const commit = page.getByRole("listbox", { name: "Commits" }).getByRole("option").first();
|
||||
const toolbar = page.getByRole("toolbar", { name: "Changed files" });
|
||||
const tree = page.getByRole("tree", { name: "Changed files" });
|
||||
const prices = tree.getByText("prices.ts", { exact: true });
|
||||
const notes = tree.getByText("checkout.md", { exact: true });
|
||||
const affected = toolbar.getByRole("button", { name: "Show Only Affected Changes" });
|
||||
const viewOptions = toolbar.getByRole("button", { name: "View Options" });
|
||||
const menu = page.getByRole("menu");
|
||||
|
||||
await commit.click();
|
||||
await expect(notes).toBeVisible();
|
||||
await expect(affected).toHaveCount(0);
|
||||
|
||||
const filter = (paths: string[]) =>
|
||||
page.evaluate(async (paths) => {
|
||||
const mod = "/src/features/vcs/logStore.ts";
|
||||
const { setLogFilters } = await import(/* @vite-ignore */ mod);
|
||||
setLogFilters({ paths });
|
||||
}, paths);
|
||||
await filter(["/dev/acme-api/src"]);
|
||||
await commit.click();
|
||||
await expect(affected).toHaveAttribute("aria-pressed", "false");
|
||||
await affected.press("Space");
|
||||
await expect(affected).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(prices).toBeVisible();
|
||||
await expect(notes).toHaveCount(0);
|
||||
|
||||
await page.setViewportSize({ width: 490, height: 550 });
|
||||
await expect(affected).toBeInViewport({ ratio: 1 });
|
||||
await expect
|
||||
.poll(() =>
|
||||
toolbar.evaluate((el) => {
|
||||
const bounds = el.getBoundingClientRect();
|
||||
return [...el.querySelectorAll("button")].every((button) => {
|
||||
const box = button.getBoundingClientRect();
|
||||
return box.left >= bounds.left && box.right <= bounds.right && box.bottom <= bounds.bottom;
|
||||
});
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
await viewOptions.click();
|
||||
await expect(menu.getByText("Layout", { exact: true })).toBeVisible();
|
||||
await expect(menu.getByRole("menuitemcheckbox", { name: "Show Only Affected Changes" })).toHaveCount(0);
|
||||
const preview = menu.getByRole("menuitemcheckbox", { name: "Show Diff Preview" });
|
||||
await expect(preview).toHaveAttribute("aria-checked", "true");
|
||||
await preview.click();
|
||||
await viewOptions.click();
|
||||
await expect(preview).toHaveAttribute("aria-checked", "false");
|
||||
await page.keyboard.press("Escape");
|
||||
await affected.click();
|
||||
await expect(notes).toBeVisible();
|
||||
|
||||
await filter([]);
|
||||
await commit.click();
|
||||
await expect(affected).toHaveCount(0);
|
||||
await expect(notes).toBeVisible();
|
||||
});
|
||||
|
||||
test("the Paths filter replaces the repository filter and can be cleared from overflow", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
@@ -61,8 +61,25 @@ test("the floating navigation list stays beside the visible segment and scrolls
|
||||
const folderRow = list.getByRole("option", { name: "archive" });
|
||||
await expect(folderRow).toHaveAttribute("aria-selected", "true");
|
||||
await expect(folderRow).toBeInViewport({ ratio: 1 });
|
||||
await expect(folderRow).toHaveCSS("height", "18px");
|
||||
await expect(folderRow).toHaveCSS("font-size", "13px");
|
||||
await expect(list.getByRole("option", { name: long, exact: true }).getByTitle(long)).toBeVisible();
|
||||
expect(await list.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
|
||||
await page.setViewportSize({ width: 1120, height: 820 });
|
||||
await expect
|
||||
.poll(() =>
|
||||
list.evaluate((el) => {
|
||||
const bounds = el.getBoundingClientRect();
|
||||
return [...el.querySelectorAll('[role="option"]')].filter((row) => {
|
||||
const box = row.getBoundingClientRect();
|
||||
return box.top >= bounds.top && box.bottom <= bounds.bottom;
|
||||
}).length;
|
||||
}),
|
||||
)
|
||||
.toBe(20);
|
||||
await page.setViewportSize({ width: 600, height: 560 });
|
||||
|
||||
await page.keyboard.press("End");
|
||||
const lastRow = list.getByRole("option", { name: last, exact: true });
|
||||
await expect(lastRow).toHaveAttribute("aria-selected", "true");
|
||||
@@ -119,6 +136,8 @@ for (const position of ["top", "statusBar"] as const) {
|
||||
const archive = list.getByRole("option", { name: "archive" });
|
||||
await expect(archive).toHaveAttribute("aria-selected", "true");
|
||||
await expect(list).toBeFocused();
|
||||
expect((await list.boundingBox())!.width).toBeLessThan(140);
|
||||
await expect(archive).toHaveCSS("height", "18px");
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const bounds = (await anchor.boundingBox())!;
|
||||
|
||||
@@ -9,6 +9,7 @@ test("gives the project name room before its path in a narrow tree", async ({ wo
|
||||
|
||||
const pane = page.getByRole("region", { name: "Project", exact: true });
|
||||
await pane.getByRole("button", { name: "Options", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "Appearance", exact: true }).hover();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Horizontal Scrolling" }).click();
|
||||
|
||||
const tree = pane.getByRole("tree", { name: "Project" });
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Locator, Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
for (const height of [990, 700, 560]) {
|
||||
test(`run configurations dialog keeps its toolbar and scrolls only inside the panes at ${height}px`, async ({
|
||||
test(`run configurations dialog keeps its toolbar and name visible while scrolling at ${height}px`, async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 900, height });
|
||||
@@ -62,9 +62,13 @@ async function resize(page: Page, dialog: Locator, dy: number) {
|
||||
async function checkScrolling(page: Page, dialog: Locator) {
|
||||
const body = dialog.locator("[data-dialog-body]");
|
||||
const list = dialog.getByRole("tree", { name: "Run configurations", exact: true });
|
||||
const form = dialog.locator('[class*="_editForm_"]');
|
||||
const form = dialog.locator('[class*="_formSettings_"]');
|
||||
const nameField = dialog.getByRole("textbox", { name: "Name", exact: true });
|
||||
await list.evaluate((el) => (el.scrollTop = 0));
|
||||
await form.evaluate((el) => (el.scrollTop = 0));
|
||||
// Measure once the dialog's opening animation has settled.
|
||||
await dialog.evaluate((el) => Promise.all(el.getAnimations().map((animation) => animation.finished)));
|
||||
const nameTop = (await nameField.boundingBox())!.y;
|
||||
await list.hover();
|
||||
await page.mouse.wheel(0, 200);
|
||||
await expect.poll(() => list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
@@ -74,6 +78,8 @@ async function checkScrolling(page: Page, dialog: Locator) {
|
||||
await page.mouse.wheel(0, 200);
|
||||
await expect.poll(() => form.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
expect(await list.evaluate((el) => el.scrollTop)).toBe(listTop);
|
||||
expect((await nameField.boundingBox())!.y).toBeCloseTo(nameTop, 0);
|
||||
await expect(dialog.getByRole("checkbox", { name: /Store as project file/ })).toBeInViewport({ ratio: 1 });
|
||||
const overflow = await body.evaluate((el) => ({
|
||||
scroll: el.scrollHeight,
|
||||
client: el.clientHeight,
|
||||
|
||||
@@ -112,7 +112,7 @@ test("resizing the configuration dialog grows its panes and keeps the footer vis
|
||||
await expect(dialog.getByRole("tree", { name: "Run configurations", exact: true })).toBeVisible();
|
||||
await expect.poll(async () => (await content.boundingBox())!.height).toBeLessThan(initial);
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollHeight - el.clientHeight))
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollHeight - el.clientHeight))
|
||||
.toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ test("Java, npm and Python forms fit narrow and zoomed content panes", async ({
|
||||
for (const width of [1024, 640, 520]) {
|
||||
await page.setViewportSize({ width, height: 820 });
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
|
||||
message: `${kind}, ${width}px, ${zoom * 100}%`,
|
||||
})
|
||||
.toBeLessThanOrEqual(1);
|
||||
@@ -204,7 +204,7 @@ for (const locale of ["en", "zh"]) {
|
||||
)
|
||||
.toMatchObject({ overflow: expect.any(Number), footerFits: true, footerVisible: true });
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth))
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth))
|
||||
.toBeLessThanOrEqual(1);
|
||||
const tasks = dialog.getByRole("list");
|
||||
await tasks.scrollIntoViewIfNeeded();
|
||||
|
||||
@@ -65,3 +65,49 @@ test("tool window header keeps its actions visible as the Project pane narrows",
|
||||
await hide.click();
|
||||
await expect(project).toBeHidden();
|
||||
});
|
||||
|
||||
test("Project options expose behavior, appearance, and sorting as submenus", async ({ workbench: page }) => {
|
||||
await openFromTree(page, "build.gradle.kts");
|
||||
await page.setViewportSize({ width: 700, height: 500 });
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/workbench/toolwindows/store.ts";
|
||||
(await import(/* @vite-ignore */ path)).setToolWindowSize("left", 185);
|
||||
});
|
||||
const header = page.locator('[data-toolwindow="project"] header');
|
||||
const options = header.getByRole("button", { name: "Options", exact: true });
|
||||
const locate = header.getByRole("button", { name: "Select Opened File", exact: true });
|
||||
await options.press("Enter");
|
||||
|
||||
const menu = page.getByRole("menu", { name: "Project options", exact: true });
|
||||
const behavior = menu.getByRole("menuitem", { name: "Behavior", exact: true });
|
||||
const appearance = menu.getByRole("menuitem", { name: "Appearance", exact: true });
|
||||
const sort = menu.getByRole("menuitem", { name: "Sort By", exact: true });
|
||||
await expect(behavior).toBeVisible();
|
||||
await expect(behavior).toBeFocused();
|
||||
await behavior.press("ArrowRight");
|
||||
const alwaysSelect = page.getByRole("menuitemcheckbox", { name: "Always Select Opened File", exact: true });
|
||||
await expect(alwaysSelect).toBeFocused();
|
||||
await expect(alwaysSelect).toHaveAttribute("aria-checked", "false");
|
||||
await alwaysSelect.press("Enter");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(locate).toBeHidden();
|
||||
|
||||
await options.press("Enter");
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await expect(appearance).toBeFocused();
|
||||
await appearance.press("ArrowRight");
|
||||
const rootPaths = page.getByRole("menuitemcheckbox", { name: "Show Root Paths", exact: true });
|
||||
await expect(rootPaths).toBeInViewport({ ratio: 1 });
|
||||
await page.keyboard.press("ArrowLeft");
|
||||
await expect(rootPaths).toBeHidden();
|
||||
await expect(appearance).toBeFocused();
|
||||
|
||||
await sort.click();
|
||||
const type = page.getByRole("menuitemcheckbox", { name: "Type", exact: true });
|
||||
await expect(type).toBeInViewport({ ratio: 1 });
|
||||
await expect(page.getByRole("menuitemcheckbox", { name: "Sort Folders First", exact: true })).toBeVisible();
|
||||
await type.click();
|
||||
await options.press("Enter");
|
||||
await sort.click();
|
||||
await expect(type).toHaveAttribute("aria-checked", "true");
|
||||
});
|
||||
@@ -46,7 +46,8 @@ test("sorts collapsed workspace roots by project type, shows their icons and ref
|
||||
.getByRole("region", { name: "Project", exact: true })
|
||||
.getByRole("button", { name: "Options", exact: true })
|
||||
.click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Sort by Type", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "Sort By", exact: true }).hover();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Type", exact: true }).click();
|
||||
await expect(tree.locator("[data-project-path]")).toHaveText([
|
||||
"rust/work/rust",
|
||||
"dart/work/dart",
|
||||
@@ -185,7 +186,8 @@ test("keeps surviving workspace icons and type order during removal", async ({ w
|
||||
const panel = page.getByRole("region", { name: "Project", exact: true });
|
||||
await panel.getByRole("button", { name: "Collapse All", exact: true }).click();
|
||||
await panel.getByRole("button", { name: "Options", exact: true }).click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Sort by Type", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "Sort By", exact: true }).hover();
|
||||
await page.getByRole("menuitemcheckbox", { name: "Type", exact: true }).click();
|
||||
const rows = tree.locator('[data-project-path^="/work/"]');
|
||||
await expect(rows).toHaveText(["z-rust/work/z-rust", "a-go/work/a-go", "b-web/work/b-web"]);
|
||||
const before = await icons();
|
||||
|
||||
@@ -20,6 +20,15 @@ run = "pnpm dev:app"
|
||||
description = "Typecheck, bundle and verify the frontend"
|
||||
run = "pnpm build"
|
||||
|
||||
[tasks."dogfood:build"]
|
||||
description = "Build a local dogfood desktop app bundle"
|
||||
run = "pnpm dogfood:build"
|
||||
|
||||
[tasks."dogfood:install"]
|
||||
description = "Build and install the local dogfood desktop app"
|
||||
depends = ["dogfood:build"]
|
||||
run = "pnpm dogfood:install --no-build"
|
||||
|
||||
[tasks.test]
|
||||
description = "Run the frontend and Rust workspace tests"
|
||||
run = ["pnpm test", "cargo test --workspace"]
|
||||
|
||||
+3
-1
@@ -33,7 +33,9 @@
|
||||
"perf": "node perf/run.ts",
|
||||
"perf:rust": "node perf/rust.ts",
|
||||
"eval": "node evals/run.ts",
|
||||
"release:prepare": "node scripts/release-prepare.ts"
|
||||
"release:prepare": "node scripts/release-prepare.ts",
|
||||
"dogfood:build": "node scripts/dogfood.ts build",
|
||||
"dogfood:install": "node scripts/dogfood.ts install"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "pnpm lint-staged"
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
// @vitest-environment node
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
DEFAULT_DOGFOOD_APP_NAME,
|
||||
dogfoodBuildEnv,
|
||||
dogfoodCliArgs,
|
||||
dogfoodPaths,
|
||||
dogfoodTauriConfig,
|
||||
generateDogfoodIcons,
|
||||
installDogfood,
|
||||
parseDogfoodArgs,
|
||||
} from "./dogfood.ts";
|
||||
|
||||
const root = fileURLToPath(new URL("..", import.meta.url));
|
||||
|
||||
describe("dogfood build and install", () => {
|
||||
it("parses build and install arguments, including pnpm separator flags", () => {
|
||||
expect(parseDogfoodArgs(["build"])).toEqual({ action: "build", skipBuild: false });
|
||||
expect(parseDogfoodArgs(["install"])).toEqual({ action: "install", skipBuild: false });
|
||||
expect(parseDogfoodArgs(["install", "--no-build"])).toEqual({ action: "install", skipBuild: true });
|
||||
expect(parseDogfoodArgs(["install", "--", "--no-build"])).toEqual({ action: "install", skipBuild: true });
|
||||
expect(() => parseDogfoodArgs([])).toThrow(/Expected 'build' or 'install'/);
|
||||
expect(() => parseDogfoodArgs(["build", "--no-build"])).toThrow(/Unexpected option/);
|
||||
});
|
||||
|
||||
it("keeps the vanilla app identifier so settings, MCP, Skills and agent sessions are shared, without updates", () => {
|
||||
const baseConfig = JSON.parse(readFileSync(join(root, "src-tauri", "tauri.conf.json"), "utf8")) as {
|
||||
identifier: string;
|
||||
};
|
||||
const override = dogfoodTauriConfig(DEFAULT_DOGFOOD_APP_NAME, ["../target/dogfood-icons/dogfood.icns"]);
|
||||
expect(baseConfig.identifier).toBe("ai.l0ng.openidea");
|
||||
expect("identifier" in override).toBe(false);
|
||||
expect(override).toEqual({
|
||||
productName: "openidea_dogfood",
|
||||
bundle: {
|
||||
createUpdaterArtifacts: false,
|
||||
icon: ["../target/dogfood-icons/dogfood.icns"],
|
||||
},
|
||||
plugins: {
|
||||
updater: { endpoints: [] },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("uses fast release compilation defaults while respecting caller overrides", () => {
|
||||
expect(dogfoodBuildEnv({})).toEqual({
|
||||
CARGO_PROFILE_RELEASE_LTO: "off",
|
||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16",
|
||||
});
|
||||
expect(dogfoodBuildEnv({ CARGO_PROFILE_RELEASE_LTO: "thin", CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "4" })).toEqual({
|
||||
CARGO_PROFILE_RELEASE_LTO: "thin",
|
||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "4",
|
||||
});
|
||||
});
|
||||
|
||||
it("resolves platform bundle arguments and install destinations", () => {
|
||||
expect(dogfoodCliArgs("openidea_dogfood", ["icon.icns"], "darwin").slice(0, 3)).toEqual([
|
||||
"build",
|
||||
"--bundles",
|
||||
"app",
|
||||
]);
|
||||
expect(dogfoodCliArgs("openidea_dogfood", ["icon.ico"], "win32").slice(0, 2)).toEqual(["build", "--no-bundle"]);
|
||||
expect(dogfoodPaths(join("/repo", "target"), "openidea_dogfood", "darwin", {})).toEqual({
|
||||
bundlePath: join("/repo", "target", "release", "bundle", "macos", "openidea_dogfood.app"),
|
||||
installPath: join("/Applications", "openidea_dogfood.app"),
|
||||
});
|
||||
expect(
|
||||
dogfoodPaths(join("/repo", "target"), "openidea_dogfood", "darwin", {
|
||||
DOGFOOD_INSTALL_DIR: "/Users/me/Applications",
|
||||
}),
|
||||
).toEqual({
|
||||
bundlePath: join("/repo", "target", "release", "bundle", "macos", "openidea_dogfood.app"),
|
||||
installPath: join("/Users/me/Applications", "openidea_dogfood.app"),
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the dogfood source SVGs geometrically identical to the vanilla icons in grey", () => {
|
||||
const sourceDir = join(root, "src-tauri", "icons", "source");
|
||||
for (const [vanillaName, dogfoodName] of [
|
||||
["openidea.svg", "openidea-dogfood.svg"],
|
||||
["openidea-windows.svg", "openidea-dogfood-windows.svg"],
|
||||
] as const) {
|
||||
const vanilla = readFileSync(join(sourceDir, vanillaName), "utf8");
|
||||
const dogfood = readFileSync(join(sourceDir, dogfoodName), "utf8");
|
||||
expect(dogfood).not.toContain("#D9582C");
|
||||
const recolored = vanilla
|
||||
.replaceAll('aria-label="OpenIDEA"', 'aria-label="OpenIDEA Dogfood"')
|
||||
.replaceAll("#EAE7E0", "#E6E7E9")
|
||||
.replaceAll("#D9582C", "#787B82")
|
||||
.replaceAll("#1B1A1A", "#1B1C1E");
|
||||
expect(dogfood).toBe(recolored);
|
||||
}
|
||||
});
|
||||
|
||||
it("generates the dogfood icon bundle with a distinct macOS .icns name", () => {
|
||||
const tempDir = mkdtempSync(join(tmpdir(), "openidea-dogfood-icons-"));
|
||||
try {
|
||||
const iconPaths = generateDogfoodIcons(root, tempDir, "darwin");
|
||||
expect(iconPaths).toHaveLength(5);
|
||||
expect(iconPaths.some((p) => p.endsWith("/dogfood.icns"))).toBe(true);
|
||||
expect(existsSync(join(tempDir, "dogfood.icns"))).toBe(true);
|
||||
expect(existsSync(join(tempDir, "[email protected]"))).toBe(true);
|
||||
expect(existsSync(join(tempDir, "icon.ico"))).toBe(true);
|
||||
const firstMtime = statSync(join(tempDir, "dogfood.icns")).mtimeMs;
|
||||
expect(generateDogfoodIcons(root, tempDir, "darwin")).toEqual(iconPaths);
|
||||
expect(statSync(join(tempDir, "dogfood.icns")).mtimeMs).toBe(firstMtime);
|
||||
} finally {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}, 30_000);
|
||||
|
||||
it("installs a macOS .app bundle into DOGFOOD_INSTALL_DIR", () => {
|
||||
if (process.platform !== "darwin") return;
|
||||
const tempDir = mkdtempSync(join(tmpdir(), "openidea-dogfood-install-"));
|
||||
const prevInstallDir = process.env.DOGFOOD_INSTALL_DIR;
|
||||
try {
|
||||
const fakeRoot = join(tempDir, "repo");
|
||||
const fakeBundle = join(fakeRoot, "target", "release", "bundle", "macos", "openidea_dogfood.app");
|
||||
mkdirSync(join(fakeBundle, "Contents", "MacOS"), { recursive: true });
|
||||
writeFileSync(join(fakeBundle, "Contents", "MacOS", "openidea"), "#!/bin/sh\n");
|
||||
const destDir = join(tempDir, "Applications");
|
||||
process.env.DOGFOOD_INSTALL_DIR = destDir;
|
||||
installDogfood(fakeRoot, "openidea_dogfood", "darwin", join(fakeRoot, "target"));
|
||||
expect(existsSync(join(destDir, "openidea_dogfood.app", "Contents", "MacOS", "openidea"))).toBe(true);
|
||||
} finally {
|
||||
if (prevInstallDir === undefined) delete process.env.DOGFOOD_INSTALL_DIR;
|
||||
else process.env.DOGFOOD_INSTALL_DIR = prevInstallDir;
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,319 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import {
|
||||
chmodSync,
|
||||
copyFileSync,
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
rmSync,
|
||||
utimesSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join, relative } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
export const DEFAULT_DOGFOOD_APP_NAME = "openidea_dogfood";
|
||||
|
||||
const LSREGISTER_PATH =
|
||||
"/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";
|
||||
|
||||
export interface DogfoodCommand {
|
||||
action: "build" | "install";
|
||||
skipBuild: boolean;
|
||||
}
|
||||
|
||||
export interface DogfoodPaths {
|
||||
bundlePath: string;
|
||||
installPath: string;
|
||||
}
|
||||
|
||||
export function parseDogfoodArgs(args: readonly string[]): DogfoodCommand {
|
||||
const filtered = args.filter((arg) => arg !== "--");
|
||||
const action = filtered[0];
|
||||
if (action !== "build" && action !== "install") {
|
||||
throw new Error(`Expected 'build' or 'install', got ${action ? `'${action}'` : "no command"}`);
|
||||
}
|
||||
let skipBuild = false;
|
||||
for (const flag of filtered.slice(1)) {
|
||||
if (action === "install" && flag === "--no-build") {
|
||||
skipBuild = true;
|
||||
} else {
|
||||
throw new Error(`Unexpected option '${flag}' for '${action}'`);
|
||||
}
|
||||
}
|
||||
return { action, skipBuild };
|
||||
}
|
||||
|
||||
/**
|
||||
* Tauri config override for local dogfood builds.
|
||||
*
|
||||
* Keeps `identifier` untouched (`ai.l0ng.openidea` from `src-tauri/tauri.conf.json`) so the
|
||||
* dogfood app shares configuration, settings, WebView storage, MCP servers, Skills, agent
|
||||
* sessions, credentials, plugins and caches with the vanilla release app.
|
||||
*
|
||||
* Clears the updater endpoints: the next release would otherwise replace the dogfood bundle
|
||||
* with the official app.
|
||||
*/
|
||||
export function dogfoodTauriConfig(appName: string, iconPaths: readonly string[]) {
|
||||
return {
|
||||
productName: appName,
|
||||
bundle: {
|
||||
createUpdaterArtifacts: false,
|
||||
icon: [...iconPaths],
|
||||
},
|
||||
plugins: {
|
||||
updater: { endpoints: [] },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function dogfoodBuildEnv(baseEnv: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
|
||||
return {
|
||||
...baseEnv,
|
||||
CARGO_PROFILE_RELEASE_LTO: baseEnv.CARGO_PROFILE_RELEASE_LTO ?? "off",
|
||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: baseEnv.CARGO_PROFILE_RELEASE_CODEGEN_UNITS ?? "16",
|
||||
};
|
||||
}
|
||||
|
||||
export function dogfoodCliArgs(
|
||||
appName: string,
|
||||
iconPaths: readonly string[],
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): string[] {
|
||||
const config = JSON.stringify(dogfoodTauriConfig(appName, iconPaths));
|
||||
if (platform === "darwin") {
|
||||
return ["build", "--bundles", "app", "--config", config];
|
||||
}
|
||||
return ["build", "--no-bundle", "--config", config];
|
||||
}
|
||||
|
||||
/** Cargo's target directory, which a `CARGO_TARGET_DIR` or `build.target-dir` setting can move. */
|
||||
export function cargoTargetDir(root: string): string {
|
||||
const result = spawnSync("cargo", ["metadata", "--format-version", "1", "--no-deps"], {
|
||||
cwd: root,
|
||||
encoding: "utf8",
|
||||
maxBuffer: 64 * 1024 * 1024,
|
||||
});
|
||||
if (result.status === 0) {
|
||||
try {
|
||||
const dir = (JSON.parse(result.stdout) as { target_directory?: unknown }).target_directory;
|
||||
if (typeof dir === "string" && dir) return dir;
|
||||
} catch {
|
||||
// Fall back to the default below.
|
||||
}
|
||||
}
|
||||
return join(root, "target");
|
||||
}
|
||||
|
||||
export function dogfoodPaths(
|
||||
targetDir: string,
|
||||
appName: string,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
): DogfoodPaths {
|
||||
const customInstallPath = env.DOGFOOD_INSTALL_PATH?.trim();
|
||||
const customInstallDir = env.DOGFOOD_INSTALL_DIR?.trim();
|
||||
if (platform === "darwin") {
|
||||
return {
|
||||
bundlePath: join(targetDir, "release", "bundle", "macos", `${appName}.app`),
|
||||
installPath: customInstallPath || join(customInstallDir || "/Applications", `${appName}.app`),
|
||||
};
|
||||
}
|
||||
if (platform === "win32") {
|
||||
const localAppData = env.LOCALAPPDATA?.trim() || join(homedir(), "AppData", "Local");
|
||||
return {
|
||||
bundlePath: join(targetDir, "release", "openidea.exe"),
|
||||
installPath: customInstallPath || join(customInstallDir || localAppData, appName),
|
||||
};
|
||||
}
|
||||
return {
|
||||
bundlePath: join(targetDir, "release", "openidea"),
|
||||
installPath: customInstallPath || join(customInstallDir || join(homedir(), ".local", "bin"), appName),
|
||||
};
|
||||
}
|
||||
|
||||
function toPosixPath(value: string): string {
|
||||
return value.replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
function runTauriIcon(root: string, cli: string, svgPath: string, outputDir: string) {
|
||||
const result = spawnSync(process.execPath, [cli, "icon", svgPath, "--output", outputDir], {
|
||||
cwd: root,
|
||||
stdio: "inherit",
|
||||
});
|
||||
if (result.error) throw result.error;
|
||||
if (result.status !== 0) throw new Error(`Dogfood icon generation failed (${result.status})`);
|
||||
}
|
||||
|
||||
export function generateDogfoodIcons(
|
||||
root: string,
|
||||
outputDir: string,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): string[] {
|
||||
const sourceDir = join(root, "src-tauri", "icons", "source");
|
||||
const svgPath = join(sourceDir, "openidea-dogfood.svg");
|
||||
const winSvgPath = join(sourceDir, "openidea-dogfood-windows.svg");
|
||||
const iconFiles = ["32x32.png", "128x128.png", "[email protected]", "dogfood.icns", "icon.ico"];
|
||||
const stampPath = join(outputDir, ".source-sha256");
|
||||
const stamp = createHash("sha256")
|
||||
.update(platform)
|
||||
.update("\0")
|
||||
.update(readFileSync(svgPath))
|
||||
.update("\0")
|
||||
.update(readFileSync(winSvgPath))
|
||||
.digest("hex");
|
||||
|
||||
// Preserve file mtimes/bytes when SVGs are unchanged so `tauri-build` does not re-link `src-tauri`.
|
||||
const upToDate =
|
||||
existsSync(stampPath) &&
|
||||
readFileSync(stampPath, "utf8").trim() === stamp &&
|
||||
iconFiles.every((file) => existsSync(join(outputDir, file)));
|
||||
|
||||
if (!upToDate) {
|
||||
const require = createRequire(import.meta.url);
|
||||
const cli = require.resolve("@tauri-apps/cli/tauri.js");
|
||||
mkdirSync(outputDir, { recursive: true });
|
||||
runTauriIcon(root, cli, svgPath, outputDir);
|
||||
|
||||
if (platform === "win32") {
|
||||
const winTemp = mkdtempSync(join(outputDir, "win-"));
|
||||
try {
|
||||
runTauriIcon(root, cli, winSvgPath, winTemp);
|
||||
copyFileSync(join(winTemp, "icon.ico"), join(outputDir, "icon.ico"));
|
||||
} finally {
|
||||
rmSync(winTemp, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
// Distinct .icns filename avoids macOS LaunchServices icon-cache collisions with OpenIDEA.app.
|
||||
copyFileSync(join(outputDir, "icon.icns"), join(outputDir, "dogfood.icns"));
|
||||
writeFileSync(stampPath, `${stamp}\n`);
|
||||
}
|
||||
|
||||
const tauriDir = join(root, "src-tauri");
|
||||
return iconFiles.map((file) => toPosixPath(relative(tauriDir, join(outputDir, file))));
|
||||
}
|
||||
|
||||
function runChecked(command: string, args: string[], options?: { cwd?: string; env?: NodeJS.ProcessEnv }) {
|
||||
const result = spawnSync(command, args, { stdio: "inherit", ...options });
|
||||
if (result.error) throw result.error;
|
||||
if (result.status !== 0) throw new Error(`${command} exited with status ${result.status}`);
|
||||
}
|
||||
|
||||
export function buildDogfood(root: string, appName: string) {
|
||||
const iconsDir = join(root, "target", "dogfood-icons");
|
||||
const iconPaths = generateDogfoodIcons(root, iconsDir);
|
||||
const args = dogfoodCliArgs(appName, iconPaths);
|
||||
runChecked(process.execPath, [join(root, "scripts", "tauri.ts"), ...args], {
|
||||
cwd: root,
|
||||
env: dogfoodBuildEnv(),
|
||||
});
|
||||
}
|
||||
|
||||
const SHARED_DATA_NOTES = [
|
||||
"The dogfood app shares its single instance with OpenIDEA: quit one before opening the other.",
|
||||
"It writes OpenIDEA's settings and data; a setting only newer builds know can make an older OpenIDEA ignore your settings file.",
|
||||
"It never updates itself: run 'pnpm dogfood:install' again to pick up new changes.",
|
||||
];
|
||||
|
||||
export function installDogfood(
|
||||
root: string,
|
||||
appName: string,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
targetDir: string = cargoTargetDir(root),
|
||||
) {
|
||||
const { bundlePath, installPath } = dogfoodPaths(targetDir, appName, platform);
|
||||
installBundle(root, appName, platform, bundlePath, installPath);
|
||||
for (const note of SHARED_DATA_NOTES) console.log(note);
|
||||
}
|
||||
|
||||
function installBundle(
|
||||
root: string,
|
||||
appName: string,
|
||||
platform: NodeJS.Platform,
|
||||
bundlePath: string,
|
||||
installPath: string,
|
||||
) {
|
||||
if (!existsSync(bundlePath)) {
|
||||
throw new Error(`Dogfood build output not found at ${bundlePath}; run 'mise run dogfood:build' first`);
|
||||
}
|
||||
|
||||
if (platform === "darwin") {
|
||||
rmSync(installPath, { recursive: true, force: true });
|
||||
mkdirSync(dirname(installPath), { recursive: true });
|
||||
runChecked("cp", ["-R", bundlePath, installPath]);
|
||||
runChecked("xattr", ["-cr", installPath]);
|
||||
const now = new Date();
|
||||
utimesSync(installPath, now, now);
|
||||
if (existsSync(LSREGISTER_PATH)) {
|
||||
spawnSync(LSREGISTER_PATH, ["-f", installPath], { stdio: "ignore" });
|
||||
}
|
||||
console.log(`Installed ${appName} to ${installPath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (platform === "win32") {
|
||||
mkdirSync(installPath, { recursive: true });
|
||||
const targetExe = join(installPath, `${appName}.exe`);
|
||||
copyFileSync(bundlePath, targetExe);
|
||||
const webviewLoader = join(dirname(bundlePath), "WebView2Loader.dll");
|
||||
if (existsSync(webviewLoader)) {
|
||||
copyFileSync(webviewLoader, join(installPath, "WebView2Loader.dll"));
|
||||
}
|
||||
console.log(`Installed ${appName} to ${targetExe}`);
|
||||
return;
|
||||
}
|
||||
|
||||
mkdirSync(dirname(installPath), { recursive: true });
|
||||
copyFileSync(bundlePath, installPath);
|
||||
chmodSync(installPath, 0o755);
|
||||
const dataHome = process.env.XDG_DATA_HOME?.trim() || join(homedir(), ".local", "share");
|
||||
const iconSource = join(root, "target", "dogfood-icons", "128x128.png");
|
||||
if (existsSync(iconSource)) {
|
||||
const iconDest = join(dataHome, "icons", "hicolor", "128x128", "apps", `${appName}.png`);
|
||||
mkdirSync(dirname(iconDest), { recursive: true });
|
||||
copyFileSync(iconSource, iconDest);
|
||||
}
|
||||
const desktopFile = join(dataHome, "applications", `${appName}.desktop`);
|
||||
mkdirSync(dirname(desktopFile), { recursive: true });
|
||||
writeFileSync(
|
||||
desktopFile,
|
||||
[
|
||||
"[Desktop Entry]",
|
||||
"Type=Application",
|
||||
`Name=${appName}`,
|
||||
`Exec=${installPath} %F`,
|
||||
`Icon=${appName}`,
|
||||
"Categories=Development;IDE;",
|
||||
"StartupWMClass=openidea",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
console.log(`Installed ${appName} to ${installPath}`);
|
||||
}
|
||||
|
||||
function main() {
|
||||
const root = realpathSync(fileURLToPath(new URL("..", import.meta.url)));
|
||||
const { action, skipBuild } = parseDogfoodArgs(process.argv.slice(2));
|
||||
const appName = process.env.DOGFOOD_APP_NAME?.trim() || DEFAULT_DOGFOOD_APP_NAME;
|
||||
if (action === "build" || !skipBuild) {
|
||||
buildDogfood(root, appName);
|
||||
}
|
||||
if (action === "install") {
|
||||
installDogfood(root, appName);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) {
|
||||
try {
|
||||
main();
|
||||
} catch (error) {
|
||||
console.error(error instanceof Error ? error.message : error);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 100 100" role="img" aria-label="OpenIDEA Dogfood">
|
||||
<rect x="2" y="2" width="96" height="96" rx="22" fill="#E6E7E9"/>
|
||||
<g transform="translate(50 50) scale(1.5) translate(-50 -52)">
|
||||
<rect x="22" y="26" width="56" height="52" rx="12" fill="#787B82"/>
|
||||
<rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1C1E"/>
|
||||
<g transform="translate(50 46) scale(1.35) translate(-50 -46)">
|
||||
<circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#E6E7E9" stroke-width="2.7"/>
|
||||
<rect x="54.3" y="42" width="2.8" height="10.5" fill="#E6E7E9"/>
|
||||
<rect x="51.2" y="42" width="5.9" height="2.5" fill="#E6E7E9"/>
|
||||
<rect x="51.2" y="50" width="9.4" height="2.5" fill="#E6E7E9"/>
|
||||
<circle cx="55.7" cy="38.4" r="1.8" fill="#E6E7E9"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Після Ширина: | Висота: | Розмір: 858 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 100 100" role="img" aria-label="OpenIDEA Dogfood"><rect x="10" y="10" width="80" height="80" rx="18" fill="#E6E7E9"/><g transform="translate(50 50) scale(1.25) translate(-50 -52)"><rect x="22" y="26" width="56" height="52" rx="12" fill="#787B82"/><rect x="27" y="26" width="46" height="42" rx="9" fill="#1B1C1E"/><circle cx="44" cy="47.4" r="4.1" fill="none" stroke="#E6E7E9" stroke-width="2.7"/><rect x="54.3" y="42" width="2.8" height="10.5" fill="#E6E7E9"/><rect x="51.2" y="42" width="5.9" height="2.5" fill="#E6E7E9"/><rect x="51.2" y="50" width="9.4" height="2.5" fill="#E6E7E9"/><circle cx="55.7" cy="38.4" r="1.8" fill="#E6E7E9"/></g></svg>
|
||||
|
Після Ширина: | Висота: | Розмір: 729 B |
@@ -591,9 +591,9 @@ function copyReference(reference: Promise<string>) {
|
||||
}
|
||||
|
||||
/** `path:12`, or `path:12-18` for a selection over several lines. */
|
||||
function pathWithLines(state: EditorState, path: string): string {
|
||||
function pathWithLines(state: EditorState, path: string, kind: "relative" | "absolute" = "relative"): string {
|
||||
const { first, last } = selectedLines(state);
|
||||
return `${pathToCopy("relative", path)}:${first}${last > first ? `-${last}` : ""}`;
|
||||
return `${pathToCopy(kind, path)}:${first}${last > first ? `-${last}` : ""}`;
|
||||
}
|
||||
|
||||
function copyPathReferencePopup(view: EditorView, slot: EditorSlot) {
|
||||
@@ -616,6 +616,11 @@ function copyPathReferencePopup(view: EditorView, slot: EditorSlot) {
|
||||
);
|
||||
const flavours = [
|
||||
{ id: "project.copyAbsolutePath", label: "Absolute Path", value: pathToCopy("absolute", path) },
|
||||
{
|
||||
id: "editor.copyAbsolutePathWithLineNumber",
|
||||
label: "Absolute Path with line number",
|
||||
value: pathWithLines(view.state, path, "absolute"),
|
||||
},
|
||||
{ id: "project.copyFileName", label: "File Name", value: pathToCopy("name", path) },
|
||||
{ id: "project.copyRelativePath", label: "Path From Content Root", value: pathToCopy("relative", path) },
|
||||
{ id: "project.copySourceRootPath", label: "Path From Source Root", value: pathToCopy("source", path) },
|
||||
@@ -639,7 +644,9 @@ function copyPathReferencePopup(view: EditorView, slot: EditorSlot) {
|
||||
preview: f.value!,
|
||||
shortcut: shortcutLabel(f.id),
|
||||
run: () => {
|
||||
void executeAction(f.id, f.id === "editor.copyPathWithLineNumber" ? f.value : path);
|
||||
const lineNumbered =
|
||||
f.id === "editor.copyPathWithLineNumber" || f.id === "editor.copyAbsolutePathWithLineNumber";
|
||||
void executeAction(f.id, lineNumbered ? f.value : path);
|
||||
},
|
||||
})),
|
||||
...contributed,
|
||||
@@ -1323,6 +1330,16 @@ export function registerEditorActions(): () => void {
|
||||
else withView((view, slot) => copyEditorPath(pathWithLines(view.state, slot.model.path)))();
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "editor.copyAbsolutePathWithLineNumber",
|
||||
title: "Copy Absolute Path with Line Number",
|
||||
category: "Edit",
|
||||
when: TEXT_WHEN,
|
||||
run: ({ arg }) => {
|
||||
if (typeof arg === "string") copyEditorPath(arg);
|
||||
else withView((view, slot) => copyEditorPath(pathWithLines(view.state, slot.model.path, "absolute")))();
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "file.save",
|
||||
title: "Save All",
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
enterInBlockComment,
|
||||
enterInDocComment,
|
||||
enterInDocstring,
|
||||
cDocTags,
|
||||
javaDocTags,
|
||||
jsDocTags,
|
||||
phpDocTags,
|
||||
@@ -20,6 +21,8 @@ const slashStar = EditorState.languageData.of(() => [
|
||||
{ commentTokens: { line: "//", block: { open: "/*", close: "*/" } } },
|
||||
]);
|
||||
const hash = EditorState.languageData.of(() => [{ commentTokens: { line: "#" } }]);
|
||||
/** What Lezer PHP reports right after `<?php\n/**`: the HTML around it. */
|
||||
const html = EditorState.languageData.of(() => [{ commentTokens: { block: { open: "<!--", close: "-->" } } }]);
|
||||
|
||||
/** `|` marks the caret. */
|
||||
function enter(text: string, language = "php", tokens = slashStar) {
|
||||
@@ -102,6 +105,38 @@ function enterBlock(text: string) {
|
||||
return { handled, text: s.doc.sliceString(0, caret) + "|" + s.doc.sliceString(caret) };
|
||||
}
|
||||
|
||||
describe("Enter after /** in PHP files and C / C++", () => {
|
||||
it("closes the stub in a PHP file where the parser reports HTML comments", () => {
|
||||
const r = enter("<?php\n/**|\nfunction add(int $a, int $b): int { return $a + $b; }", "php", html);
|
||||
expect(r.text).toBe(
|
||||
"<?php\n/**\n * |\n * @param int $a\n * @param int $b\n * @return int\n */\nfunction add(int $a, int $b): int { return $a + $b; }",
|
||||
);
|
||||
});
|
||||
|
||||
it("lists a C or C++ function's parameters and return value", () => {
|
||||
expect(enter("<p>/**|</p>", "html", html).handled).toBe(false);
|
||||
expect(enter("/**|\nint add(int a, int b) { return a + b; }", "c").text).toBe(
|
||||
"/**\n * |\n * @param a\n * @param b\n * @return\n */\nint add(int a, int b) { return a + b; }",
|
||||
);
|
||||
expect(cDocTags("static const char *name(const struct S *s, size_t n[]);")).toEqual([
|
||||
"@param s",
|
||||
"@param n",
|
||||
"@return",
|
||||
]);
|
||||
expect(cDocTags("void run(void) {}")).toEqual([]);
|
||||
expect(cDocTags("void *alloc(size_t size, int flags = 0) {}")).toEqual(["@param size", "@param flags", "@return"]);
|
||||
expect(cDocTags("template <typename T> std::vector<T> Box<T>::take(const T &x, ...) const {")).toEqual([
|
||||
"@param x",
|
||||
"@return",
|
||||
]);
|
||||
expect(cDocTags("explicit Widget(int w) : w_(w) {}")).toEqual(["@param w"]);
|
||||
expect(cDocTags("Widget(int w) {}")).toEqual(["@param w"]);
|
||||
expect(cDocTags("struct S { int a; };")).toEqual([]);
|
||||
expect(cDocTags("return add(a, b);")).toEqual([]);
|
||||
expect(cDocTags('printf("%d", x);')).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Enter in a /* */ comment", () => {
|
||||
it("starts the new line with a leading asterisk aligned under the comment's", () => {
|
||||
expect(enterBlock("/**\n * xxxx|\n **/\nclass A {}").text).toBe("/**\n * xxxx\n * |\n **/\nclass A {}");
|
||||
|
||||
@@ -78,6 +78,45 @@ function javaDeclaration(text: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
const C_SPECIFIERS =
|
||||
/^(static|inline|extern|virtual|explicit|constexpr|consteval|friend|const|volatile|unsigned|signed|long|short|struct|enum|union|\[\[[^\]]*\]\])\s+/;
|
||||
|
||||
/**
|
||||
* Doxygen tags for the C / C++ function declared at the start of `text`: `@param` per named
|
||||
* parameter (default values and arrays dropped, `void` and `...` skipped) and `@return` unless it
|
||||
* returns `void` or is a constructor / destructor. A type, a call or a statement gets none.
|
||||
*/
|
||||
export function cDocTags(text: string): string[] {
|
||||
let s = text.trimStart();
|
||||
if (/^template\s*</.test(s)) {
|
||||
const end = closing(s, s.indexOf("<"));
|
||||
if (end < 0) return [];
|
||||
s = s.slice(end).trimStart();
|
||||
}
|
||||
for (let m = C_SPECIFIERS.exec(s); m; m = C_SPECIFIERS.exec(s)) s = s.slice(m[0].length);
|
||||
const open = s.indexOf("(");
|
||||
if (open < 0) return [];
|
||||
const head = s.slice(0, open).trim();
|
||||
// `Type name`, `Type *name`, `Type Class::name`, or a lone `Name` / `~Name` for constructors.
|
||||
const m = /^(?:([\w:<>,\s*&]+?)\s*([*&]+\s*|\s+))?((?:[\w:]*(?:<[^()]*>)?::)?~?\w+)$/.exec(head);
|
||||
const statement = /^(return|if|while|for|switch|sizeof|case|else|do|new|delete|throw|goto)$/;
|
||||
if (!m || statement.test(m[3]!) || statement.test((m[1] ?? "").trim().split(/\s+/)[0]!)) return [];
|
||||
const end = closing(s, open);
|
||||
if (end < 0 || !/^\s*(const\s*)?(noexcept\s*)?(override\s*)?(->\s*[^{;]+)?(:[^{;]*)?\s*(\{|;|$)/.test(s.slice(end)))
|
||||
return [];
|
||||
const params = splitTopLevel(s.slice(open + 1, end - 1), true).flatMap((p) => {
|
||||
const t = p.replace(/=.*$/s, "").trim();
|
||||
if (!t || t === "void" || t === "...") return [];
|
||||
// A parameter without a name (`int`) has nothing to document.
|
||||
const name = /(\w+)\s*(\[[^\]]*\]\s*)*$/.exec(t)?.[1];
|
||||
return name && /[\s*&]/.test(t) ? [name] : [];
|
||||
});
|
||||
const tags = params.map((n) => `@param ${n}`);
|
||||
const returnType = (m[1] ?? "").trim();
|
||||
if (returnType && !(returnType === "void" && !(m[2] ?? "").includes("*"))) tags.push("@return");
|
||||
return tags;
|
||||
}
|
||||
|
||||
/** Type parameter names of `<T extends A, U>`. */
|
||||
function typeParams(list: string): string[] {
|
||||
return splitTopLevel(list.slice(1, -1), true).flatMap((p) => /^\s*(\w+)/.exec(p)?.[1] ?? []);
|
||||
@@ -254,6 +293,16 @@ export const enterInDocstring: Command = (view) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether the comments at `pos` include `/* *\/` ones. Embedded languages list several comment
|
||||
* styles there (PHP after HTML's `<!-- -->`), so every entry counts, not only the first.
|
||||
*/
|
||||
function hasCBlockComments(state: EditorState, pos: number): boolean {
|
||||
return state
|
||||
.languageDataAt<{ block?: { open: string; close: string } }>("commentTokens", pos)
|
||||
.some((t) => t.block?.open === "/*" && t.block.close === "*/");
|
||||
}
|
||||
|
||||
/** The Enter command for documents of `language` (stub tags in PHP). */
|
||||
export function enterInDocComment(language: string | undefined): Command {
|
||||
return (view) => {
|
||||
@@ -261,8 +310,9 @@ export function enterInDocComment(language: string | undefined): Command {
|
||||
if (state.readOnly || state.selection.ranges.length !== 1) return false;
|
||||
const r = state.selection.main;
|
||||
if (!r.empty) return false;
|
||||
const block = state.languageDataAt<{ block?: { open: string; close: string } }>("commentTokens", r.head)[0]?.block;
|
||||
if (block?.open !== "/*" || block.close !== "*/") return false;
|
||||
// Lezer PHP leaves `<?php` + an unclosed `/**` to the HTML around it, whose comments are
|
||||
// `<!-- -->`; PHP code always takes `/* */`.
|
||||
if (language !== "php" && !hasCBlockComments(state, r.head)) return false;
|
||||
const line = state.doc.lineAt(r.head);
|
||||
const before = line.text.slice(0, r.head - line.from);
|
||||
if (before.trim() !== "/**" || line.text.slice(r.head - line.from).trim()) return false;
|
||||
@@ -280,7 +330,9 @@ export function enterInDocComment(language: string | undefined): Command {
|
||||
? javaDocTags(code)
|
||||
: /^(java|type)script(react)?$/.test(language ?? "")
|
||||
? jsDocTags(code)
|
||||
: [];
|
||||
: /^(c|cpp|objective-c|objective-cpp)$/.test(language ?? "")
|
||||
? cDocTags(code)
|
||||
: [];
|
||||
const summary = `${br}${indent} * `;
|
||||
const insert = summary + tags.map((t) => `${br}${indent} * ${t}`).join("") + `${br}${indent} */`;
|
||||
view.dispatch(
|
||||
|
||||
@@ -309,6 +309,54 @@ describe("Python indentation", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("C++ access specifiers", async () => {
|
||||
const cpp = (await loadSupport(languages.find((l) => l.name === "C++")!))!;
|
||||
|
||||
it("lines up with the class as its colon is typed, and the members below stay indented", () => {
|
||||
const v = make("namespace n {\n class A {\n |\n };\n}", [cpp, indentUnit.of(" "), indentOnInput()]);
|
||||
for (const ch of "public:") {
|
||||
const at = v.state.selection.main.head;
|
||||
v.dispatch({ changes: { from: at, insert: ch }, selection: { anchor: at + 1 }, userEvent: "input.type" });
|
||||
}
|
||||
expect(show(v)).toBe("namespace n {\n class A {\n public:|\n };\n}");
|
||||
insertNewlineAndIndent(v);
|
||||
expect(show(v)).toBe("namespace n {\n class A {\n public:\n |\n };\n}");
|
||||
});
|
||||
|
||||
it("leaves a scope qualifier alone", () => {
|
||||
const v = make("class A {\n |\n};", [cpp, indentUnit.of(" "), indentOnInput()]);
|
||||
for (const ch of "std::") {
|
||||
const at = v.state.selection.main.head;
|
||||
v.dispatch({ changes: { from: at, insert: ch }, selection: { anchor: at + 1 }, userEvent: "input.type" });
|
||||
}
|
||||
expect(show(v)).toBe("class A {\n std::|\n};");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Enter after a case label", async () => {
|
||||
const load = async (name: string) => (await loadSupport(languages.find((l) => l.name === name)!))!;
|
||||
const [c, cpp, php] = await Promise.all([load("C"), load("C++"), load("PHP")]);
|
||||
|
||||
it("indents the branch body one level in C, C++ and PHP", () => {
|
||||
for (const [support, head] of [
|
||||
[c, "int f(int x) {\n switch (x) {\n case 1:|\n }\n}"],
|
||||
[cpp, "int f(int x) {\n switch (x) {\n default:|\n }\n}"],
|
||||
[php, "<?php\nfunction f($x) {\n switch ($x) {\n case 'a':|\n }\n}"],
|
||||
] as const) {
|
||||
const v = make(head, [support, indentUnit.of(" ")]);
|
||||
insertNewlineAndIndent(v);
|
||||
const lines = show(v).split("\n");
|
||||
expect(lines.find((l) => l.includes("|"))).toBe(" |");
|
||||
}
|
||||
});
|
||||
|
||||
it("leaves other lines alone", () => {
|
||||
const v = make("void f() {\n std::|\n}", [cpp, indentUnit.of(" ")]);
|
||||
insertNewlineAndIndent(v);
|
||||
expect(show(v).split("\n")[2]).toBe(" |");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Kotlin continuation indentation", async () => {
|
||||
const kt = (await loadSupport(languages.find((l) => l.name === "Kotlin")!))!;
|
||||
const ext = [kt, indentUnit.of(" ")];
|
||||
|
||||
@@ -584,7 +584,12 @@ export const KEYWORD_BLOCK_LANGS = new Set([
|
||||
const KEYWORD_HEAD =
|
||||
/\b(do(\s*\|[^|]*\|)?|then|where|of)$|^\s*(def|defp|defmodule|class|module|function|local function|if|unless|elsif|elseif|else|while|until|for|case|begin)\b/;
|
||||
const BLOCK_HEAD =
|
||||
/^\s*(if|else|for|while|do|switch|try|catch|finally|fn|fun|func|function|class|struct|enum|impl|trait|interface|object|match|when|loop|unsafe|mod|namespace)\b/;
|
||||
/^\s*(if|else|elseif|for|foreach|while|do|switch|try|catch|finally|fn|fun|func|function|class|struct|enum|impl|trait|interface|object|match|when|loop|unsafe|mod|namespace)\b/;
|
||||
/** Languages whose `struct` / `class` / `union` / `enum` definitions end with `};`. */
|
||||
const C_TYPE_LANGS = new Set(["c", "cpp", "objective-c", "objective-cpp"]);
|
||||
/** `struct S`, `class A : public B`, `enum class E : int`, `template <typename T> class A`. */
|
||||
const C_TYPE_HEAD =
|
||||
/^\s*(template\s*<[^>]*>\s*)?(typedef\s+)?(struct|class|union|enum(\s+(class|struct))?)(\s+[\w:]+)?(\s+final)?(\s*:\s*[^{};()]+)?\s*$/;
|
||||
/** A function header that names the function but has no parameter list yet. */
|
||||
const FUNCTION_NAME_ONLY = new RegExp(
|
||||
String.raw`^\s*((pub(\([^)]*\))?|async|const|unsafe|extern|export|default|static|private|public|protected|internal|open|override|suspend|inline|operator|infix|tailrec)\s+)*(func|fn|fun|function)\s+[\w$]+(<[^>]*>)?$`,
|
||||
@@ -608,7 +613,7 @@ const PAREN_CONDITION_LANGS = new Set([
|
||||
"objective-cpp",
|
||||
]);
|
||||
/** A condition keyword with nothing after it yet (`for`, `} else if`). */
|
||||
export const BARE_CONDITION = /^\s*(\}\s*)?(else\s+)?(if|for|while|switch|catch|synchronized)$/;
|
||||
export const BARE_CONDITION = /^\s*(\}\s*)?(else\s+)?(if|elseif|for|foreach|while|switch|catch|synchronized)$/;
|
||||
const MODIFIERS =
|
||||
"public|protected|private|internal|static|final|abstract|sealed|non-sealed|open|data|export|default|async|override|partial|readonly|unsafe|const|extern|inline|virtual|synchronized|native|strictfp|transient";
|
||||
const ANNOTATIONS = String.raw`(@[\w.]+(\([^)]*\))?\s+)*`;
|
||||
@@ -628,6 +633,7 @@ const METHOD_HEAD_LANGS = new Set(["java", "csharp", "groovy"]);
|
||||
export function isBlockHead(code: string, language: string): boolean {
|
||||
if (KEYWORD_BLOCK_LANGS.has(language) || /[{;,]$/.test(code)) return false;
|
||||
if (BLOCK_HEAD.test(code) || DECLARATION_HEAD.test(code) || FUNCTION_NAME_ONLY.test(code)) return true;
|
||||
if (C_TYPE_LANGS.has(language) && C_TYPE_HEAD.test(code)) return true;
|
||||
return (
|
||||
METHOD_HEAD_LANGS.has(language) &&
|
||||
!STATEMENT_WORDS.test(code) &&
|
||||
@@ -759,7 +765,9 @@ export function completeStatementSpec(state: EditorState, language: string): Tra
|
||||
if (braces && !comment && isBlockHead(text, language)) {
|
||||
// `func f` / `fn f` / `fun f` → `f()`: a function needs its parameter list.
|
||||
const params = FUNCTION_NAME_ONLY.test(text) ? "()" : "";
|
||||
const insert = `${params} {${br}${baseIndent}${unit}${br}${baseIndent}}`;
|
||||
// A C / C++ type definition ends with `};`.
|
||||
const close = C_TYPE_LANGS.has(language) && C_TYPE_HEAD.test(text) ? "};" : "}";
|
||||
const insert = `${params} {${br}${baseIndent}${unit}${br}${baseIndent}${close}`;
|
||||
const from = line.from + text.length;
|
||||
return {
|
||||
// A trailing comment moves to the end of the header line.
|
||||
|
||||
@@ -540,7 +540,16 @@ function unbalanced(code: string): boolean {
|
||||
return depth > 0;
|
||||
}
|
||||
|
||||
/** Extensions the stock modes lack, by CodeMirror language name. */
|
||||
/** Enter after a `case 1:` / `default:` label with nothing after the caret: the branch body goes one level deeper. */
|
||||
const caseBodyIndent = indentService.of((cx, pos) => {
|
||||
if (cx.simulatedBreak == null || cx.textAfterPos(pos).trim()) return undefined;
|
||||
const line = cx.state.doc.lineAt(pos);
|
||||
const before = line.text.slice(0, pos - line.from);
|
||||
const code = indentationCode(before, "//").trimEnd();
|
||||
if (!/^\s*(case\b[^;{}]*|default\s*):$/.test(code) || /::$/.test(code)) return undefined;
|
||||
return cx.countColumn(before, before.search(/\S|$/)) + cx.unit;
|
||||
});
|
||||
|
||||
/**
|
||||
* Kotlin: Enter after a `when` branch's `->` or an assignment's `=` with nothing after it
|
||||
* continues one level deeper (the branch body or the assigned expression follows), as IDEA does.
|
||||
@@ -554,9 +563,31 @@ const kotlinContinuation = indentService.of((cx, pos) => {
|
||||
return cx.countColumn(before, before.search(/\S|$/)) + cx.unit;
|
||||
});
|
||||
|
||||
const ACCESS_SPECIFIER = /^\s*(public|protected|private)\s*:(?!:)/;
|
||||
|
||||
/**
|
||||
* C++: an access specifier (`public:`) lines up with its class, not with the members below it, and
|
||||
* moves there as its `:` is typed.
|
||||
*/
|
||||
const cppAccessSpecifierIndent = [
|
||||
indentService.of((cx, pos) => {
|
||||
const line = cx.state.doc.lineAt(pos);
|
||||
if (pos !== line.from || !ACCESS_SPECIFIER.test(cx.textAfterPos(pos))) return undefined;
|
||||
const at = line.from + /^\s*/.exec(line.text)![0].length;
|
||||
for (let n: SyntaxNode | null = syntaxTree(cx.state).resolveInner(at, 1); n; n = n.parent)
|
||||
if (n.name === "FieldDeclarationList") return cx.lineIndent(n.from, 1);
|
||||
return undefined;
|
||||
}),
|
||||
EditorState.languageData.of(() => [{ indentOnInput: /^\s*(public|protected|private)\s*:$/ }]),
|
||||
];
|
||||
|
||||
/** Extensions the stock modes lack, by CodeMirror language name. */
|
||||
const EXTRA_SUPPORT: Record<string, Extension[]> = {
|
||||
Java: [annotationIndent],
|
||||
Python: pythonDedent,
|
||||
C: [caseBodyIndent],
|
||||
"C++": [...cppAccessSpecifierIndent, caseBodyIndent],
|
||||
PHP: [caseBodyIndent],
|
||||
Kotlin: [kotlinContinuation],
|
||||
};
|
||||
|
||||
|
||||
@@ -352,8 +352,27 @@ describe("smart angle brackets", () => {
|
||||
const KOTLIN = StreamLanguage.define(interpolationParser(kotlin, "Kotlin"));
|
||||
const CSHARP = StreamLanguage.define(interpolationParser(csharp, "C#"));
|
||||
let RUST: LanguageSupport;
|
||||
let CPP: LanguageSupport;
|
||||
beforeAll(async () => {
|
||||
RUST = (await cmLanguages.find((l) => l.name === "Rust")!.load()) as LanguageSupport;
|
||||
CPP = (await cmLanguages.find((l) => l.name === "C++")!.load()) as LanguageSupport;
|
||||
});
|
||||
|
||||
it("pairs include brackets in C and C++, and template arguments in C++", () => {
|
||||
pair("c", CPP, "#include |", "#include <|>");
|
||||
pair("cpp", CPP, "#include |", "#include <|>");
|
||||
pair("cpp", CPP, "std::vector|", "std::vector<|>");
|
||||
pair("cpp", CPP, "auto p = std::make_unique|", "auto p = std::make_unique<|>");
|
||||
pair("cpp", CPP, "auto n = static_cast|", "auto n = static_cast<|>");
|
||||
pair("cpp", CPP, "template |", "template <|>");
|
||||
pair("cpp", CPP, "Box|", "Box<|>");
|
||||
});
|
||||
|
||||
it("does not pair comparisons, shifts or macros in C and C++", () => {
|
||||
pair("c", CPP, "int f() { return a |", "int f() { return a <|");
|
||||
pair("cpp", CPP, "for (int i = 0; i|", "for (int i = 0; i<|");
|
||||
pair("cpp", CPP, "std::cout |", "std::cout <|");
|
||||
pair("cpp", CPP, "if (x < MAX|", "if (x < MAX<|");
|
||||
});
|
||||
|
||||
it("pairs after a type name in Java: fields, type arguments and class declarations", () => {
|
||||
|
||||
@@ -273,13 +273,16 @@ function wordBefore(state: EditorState, pos: number): string {
|
||||
}
|
||||
|
||||
/** The caret is inside a literal: never pair there, whatever the language rule says. */
|
||||
/** C++ template syntax, not a template literal. */
|
||||
const CPP_TEMPLATE_NODE = /^Template(Function|Type|Method|ArgumentList|ParameterList|Declaration|Instantiation)$/;
|
||||
|
||||
function inLiteral(state: EditorState, pos: number): boolean {
|
||||
for (
|
||||
let n: ReturnType<ReturnType<typeof syntaxTree>["resolveInner"]> | null = syntaxTree(state).resolveInner(pos, -1);
|
||||
n;
|
||||
n = n.parent
|
||||
)
|
||||
if (/string|comment|template|rune/i.test(n.name)) return true;
|
||||
if (/string|comment|template|rune/i.test(n.name) && !CPP_TEMPLATE_NODE.test(n.name)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -360,6 +363,85 @@ function cLikeTypePosition(state: EditorState, pos: number): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
/** Standard C++ templates (and casts) written against their `<`. */
|
||||
const CPP_TEMPLATES = new Set([
|
||||
"vector",
|
||||
"array",
|
||||
"deque",
|
||||
"list",
|
||||
"forward_list",
|
||||
"map",
|
||||
"multimap",
|
||||
"set",
|
||||
"multiset",
|
||||
"unordered_map",
|
||||
"unordered_multimap",
|
||||
"unordered_set",
|
||||
"unordered_multiset",
|
||||
"stack",
|
||||
"queue",
|
||||
"priority_queue",
|
||||
"pair",
|
||||
"tuple",
|
||||
"optional",
|
||||
"variant",
|
||||
"any",
|
||||
"function",
|
||||
"span",
|
||||
"basic_string",
|
||||
"unique_ptr",
|
||||
"shared_ptr",
|
||||
"weak_ptr",
|
||||
"make_unique",
|
||||
"make_shared",
|
||||
"atomic",
|
||||
"future",
|
||||
"promise",
|
||||
"initializer_list",
|
||||
"numeric_limits",
|
||||
"is_same",
|
||||
"enable_if",
|
||||
"conditional",
|
||||
"decay",
|
||||
"remove_reference",
|
||||
"static_cast",
|
||||
"dynamic_cast",
|
||||
"const_cast",
|
||||
"reinterpret_cast",
|
||||
"duration_cast",
|
||||
"get",
|
||||
"hash",
|
||||
"less",
|
||||
"greater",
|
||||
"allocator",
|
||||
"reference_wrapper",
|
||||
"string_view",
|
||||
"bitset",
|
||||
"complex",
|
||||
"valarray",
|
||||
]);
|
||||
|
||||
/** `#include <` in C and C++. */
|
||||
function includePosition(state: EditorState, pos: number): boolean {
|
||||
const line = state.doc.lineAt(pos);
|
||||
return /^\s*#\s*(include|include_next|import)\s*$/.test(line.text.slice(0, pos - line.from));
|
||||
}
|
||||
|
||||
/**
|
||||
* C++: `#include <`, `template <`, and a template name written against its `<`: a standard one
|
||||
* (`std::vector<`, `static_cast<`) or a capitalized one (`Box<`), never a value (`a < b`, `i<n`)
|
||||
* or an all-caps macro.
|
||||
*/
|
||||
function cppTypePosition(state: EditorState, pos: number): boolean {
|
||||
if (includePosition(state, pos)) return true;
|
||||
const line = state.doc.lineAt(pos);
|
||||
const before = line.text.slice(0, pos - line.from);
|
||||
if (/\btemplate\s*$/.test(before)) return true;
|
||||
const name = /(?:^|[^\w])(\w+)$/.exec(before)?.[1];
|
||||
if (!name || /\boperator$/.test(before)) return false;
|
||||
return CPP_TEMPLATES.has(name) || (/^[A-Z]/.test(name) && /[a-z]/.test(name));
|
||||
}
|
||||
|
||||
const ANGLE_PAIR_RULES: Record<string, (state: EditorState, pos: number) => boolean> = {
|
||||
java: javaTypePosition,
|
||||
typescript: tsTypePosition,
|
||||
@@ -367,6 +449,10 @@ const ANGLE_PAIR_RULES: Record<string, (state: EditorState, pos: number) => bool
|
||||
kotlin: cLikeTypePosition,
|
||||
csharp: cLikeTypePosition,
|
||||
rust: rustTypePosition,
|
||||
c: includePosition,
|
||||
cpp: cppTypePosition,
|
||||
"objective-c": includePosition,
|
||||
"objective-cpp": cppTypePosition,
|
||||
};
|
||||
|
||||
/** The `<>` pairs the smart angle brackets inserted; `>` steps over their closing half. */
|
||||
|
||||
@@ -270,6 +270,49 @@ describe("completeStatementSpec (text rules)", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("completeStatementSpec: foreach and elseif", () => {
|
||||
const ext = [comments("//"), indentUnit.of(" ")];
|
||||
it("gives a PHP or C# foreach a body instead of ending it with `;`", () => {
|
||||
for (const [head, language] of [
|
||||
["foreach ($xs as $x)", "php"],
|
||||
["foreach ($map as $k => $v)", "php"],
|
||||
["elseif ($x)", "php"],
|
||||
["foreach (var x in xs)", "csharp"],
|
||||
] as const) {
|
||||
const s = state(`${head}|`, ext);
|
||||
expect(withCaret(s, completeStatementSpec(s, language))).toBe(`${head} {\n |\n}`);
|
||||
}
|
||||
const bare = state("foreach|", ext);
|
||||
expect(withCaret(bare, completeStatementSpec(bare, "php"))).toBe("foreach (|) {\n}");
|
||||
});
|
||||
});
|
||||
|
||||
describe("completeStatementSpec: C and C++ type definitions", () => {
|
||||
const ext = [comments("//"), indentUnit.of(" ")];
|
||||
it("ends a struct, class, union or enum with `};`", () => {
|
||||
for (const [head, language] of [
|
||||
["struct S", "c"],
|
||||
["typedef struct Node", "c"],
|
||||
["union U", "c"],
|
||||
["enum Color", "c"],
|
||||
["class A", "cpp"],
|
||||
["class B : public A", "cpp"],
|
||||
["enum class E : int", "cpp"],
|
||||
["template <typename T> class Box", "cpp"],
|
||||
] as const) {
|
||||
const s = state(`${head}|`, ext);
|
||||
expect(withCaret(s, completeStatementSpec(s, language))).toBe(`${head} {\n |\n};`);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps a plain `}` for namespaces and control flow", () => {
|
||||
for (const head of ["if (x)", "namespace n"]) {
|
||||
const s = state(`${head}|`, ext);
|
||||
expect(withCaret(s, completeStatementSpec(s, "cpp"))).toBe(`${head} {\n |\n}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("completeStatementSpec: TypeScript and Python", () => {
|
||||
const ts = [comments("//", ["/*", "*/"]), indentUnit.of(" ")];
|
||||
const py = [comments("#"), indentUnit.of(" ")];
|
||||
|
||||
@@ -100,6 +100,13 @@ describe("editor Copy Path/Reference chooser", () => {
|
||||
expect(hint).toHaveBeenCalledWith({ text: `Copied ${path}` });
|
||||
});
|
||||
|
||||
it("registers Copy Absolute Path with Line Number in Find Action", () => {
|
||||
expect(getAction("editor.copyAbsolutePathWithLineNumber")).toMatchObject({
|
||||
title: "Copy Absolute Path with Line Number",
|
||||
category: "Edit",
|
||||
});
|
||||
});
|
||||
|
||||
it("opens at the caret without copying, with every preview and assigned shortcut", async () => {
|
||||
vi.spyOn(ctrl.activeSlot!.view!, "coordsAtPos").mockReturnValue({ left: 120, right: 121, top: 80, bottom: 100 });
|
||||
useKeymap.setState({ overrides: { "project.copyFileName": ["Meta+Alt+N"] } });
|
||||
@@ -109,6 +116,7 @@ describe("editor Copy Path/Reference chooser", () => {
|
||||
expect(popup().anchor).toEqual({ x: 120, y: 100 });
|
||||
expect(popup().items.map(({ label, preview }) => [label, preview])).toEqual([
|
||||
["Absolute Path", path],
|
||||
["Absolute Path with line number", `${path}:2`],
|
||||
["File Name", "A.java"],
|
||||
["Path From Content Root", "src/A.java"],
|
||||
["Path From Source Root", "A.java"],
|
||||
@@ -116,11 +124,12 @@ describe("editor Copy Path/Reference chooser", () => {
|
||||
["Reference", "com.acme.A"],
|
||||
]);
|
||||
for (const item of popup().items) expect(item.shortcut).toBe(shortcutLabel(item.id));
|
||||
expect(popup().items[1]!.shortcut).toBeTruthy();
|
||||
expect(popup().items.find((item) => item.id === "project.copyFileName")!.shortcut).toBeTruthy();
|
||||
});
|
||||
|
||||
it.each([
|
||||
"project.copyAbsolutePath",
|
||||
"editor.copyAbsolutePathWithLineNumber",
|
||||
"project.copyFileName",
|
||||
"project.copyRelativePath",
|
||||
"project.copySourceRootPath",
|
||||
@@ -147,23 +156,28 @@ describe("editor Copy Path/Reference chooser", () => {
|
||||
useProjectTree.setState({ root: null });
|
||||
useContextKeys.setState({ projectOpen: false });
|
||||
await executeAction("editor.copyPathReference");
|
||||
expect(popup().items.find((item) => item.id === "editor.copyPathWithLineNumber")?.preview).toBe(`${path}:2`);
|
||||
for (const id of ["editor.copyPathWithLineNumber", "editor.copyAbsolutePathWithLineNumber"])
|
||||
expect(popup().items.find((item) => item.id === id)?.preview).toBe(`${path}:2`);
|
||||
await popup()
|
||||
.items.find((item) => item.id === "project.copyRelativePath")!
|
||||
.run();
|
||||
expect(writeText).toHaveBeenCalledExactlyOnceWith(path);
|
||||
});
|
||||
|
||||
it("copies a selection over several lines as path:first-last", async () => {
|
||||
it("copies relative and absolute selections over several lines as path:first-last", async () => {
|
||||
const view = ctrl.activeSlot!.view!;
|
||||
view.dispatch({ selection: { anchor: 0, head: documentText.indexOf("A {}") } });
|
||||
await executeAction("editor.copyPathReference");
|
||||
const item = popup().items.find((item) => item.id === "editor.copyPathWithLineNumber")!;
|
||||
expect(item.preview).toBe("src/A.java:1-2");
|
||||
const absolute = popup().items.find((item) => item.id === "editor.copyAbsolutePathWithLineNumber")!;
|
||||
expect(absolute.preview).toBe(`${path}:1-2`);
|
||||
// A selection that ends at the start of a line leaves that line out.
|
||||
view.dispatch({ selection: { anchor: 0, head: documentText.indexOf("class") } });
|
||||
await executeAction("editor.copyPathWithLineNumber");
|
||||
await vi.waitFor(() => expect(writeText).toHaveBeenLastCalledWith("src/A.java:1"));
|
||||
await executeAction("editor.copyAbsolutePathWithLineNumber");
|
||||
await vi.waitFor(() => expect(writeText).toHaveBeenLastCalledWith(`${path}:1`));
|
||||
});
|
||||
|
||||
it("uses path:line off a symbol and ignores stale reference resolution", async () => {
|
||||
@@ -178,6 +192,18 @@ describe("editor Copy Path/Reference chooser", () => {
|
||||
expect(popup().items).toEqual([]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["editor.copyPathWithLineNumber", "src/A.java:2"],
|
||||
["editor.copyAbsolutePathWithLineNumber", `${path}:2`],
|
||||
])("copies the %s preview even if the caret moves afterwards", async (id, expected) => {
|
||||
await executeAction("editor.copyPathReference");
|
||||
const item = popup().items.find((item) => item.id === id)!;
|
||||
expect(item.preview).toBe(expected);
|
||||
ctrl.activeSlot!.view!.dispatch({ selection: { anchor: 0 } });
|
||||
await item.run();
|
||||
await vi.waitFor(() => expect(writeText).toHaveBeenCalledExactlyOnceWith(expected));
|
||||
});
|
||||
|
||||
it("copies the reference preview even if the caret moves afterwards", async () => {
|
||||
await executeAction("editor.copyPathReference");
|
||||
await vi.waitFor(() => expect(popup().items.at(-1)?.disabled).toBeNull());
|
||||
@@ -190,11 +216,11 @@ describe("editor Copy Path/Reference chooser", () => {
|
||||
it("supports keyboard selection and Escape through the existing list popup", async () => {
|
||||
await executeAction("editor.copyPathReference");
|
||||
render(<LspPopups />);
|
||||
expect(screen.getAllByRole("option")).toHaveLength(6);
|
||||
expect(screen.getAllByRole("option")).toHaveLength(7);
|
||||
expect(screen.getByTitle(path)).toBeInTheDocument();
|
||||
fireEvent.keyDown(screen.getByRole("listbox"), { key: "ArrowDown" });
|
||||
fireEvent.keyDown(screen.getByRole("listbox"), { key: "Enter" });
|
||||
await vi.waitFor(() => expect(writeText).toHaveBeenCalledExactlyOnceWith("A.java"));
|
||||
await vi.waitFor(() => expect(writeText).toHaveBeenCalledExactlyOnceWith(`${path}:2`));
|
||||
expect(useLspPopup.getState().popup).toBeNull();
|
||||
await act(() => executeAction("editor.copyPathReference"));
|
||||
fireEvent.keyDown(screen.getByRole("listbox"), { key: "Escape" });
|
||||
|
||||
@@ -227,16 +227,14 @@
|
||||
}
|
||||
.find {
|
||||
display: grid;
|
||||
grid-template-columns: [mode] auto [field] minmax(0, 420px) [actions] fit-content(50%) [close] minmax(
|
||||
min-content,
|
||||
1fr
|
||||
);
|
||||
grid-template-columns: [mode] auto [field] minmax(0, max(240px, 33%)) [actions] fit-content(50%) minmax(0, 1fr);
|
||||
align-items: start;
|
||||
row-gap: var(--space-1);
|
||||
padding: var(--space-1-5) var(--space-2);
|
||||
}
|
||||
.findExpand {
|
||||
grid-area: 1 / mode;
|
||||
margin-block-start: var(--space-1);
|
||||
margin-inline-end: var(--space-1);
|
||||
}
|
||||
.findField {
|
||||
@@ -249,15 +247,6 @@
|
||||
.replaceField {
|
||||
min-width: 0;
|
||||
}
|
||||
.findClose {
|
||||
grid-area: 1 / close;
|
||||
justify-self: end;
|
||||
margin-inline-start: var(--space-1);
|
||||
}
|
||||
.findExpand,
|
||||
.findClose {
|
||||
margin-block-start: var(--space-1);
|
||||
}
|
||||
.findButtons,
|
||||
.replaceButtons {
|
||||
display: flex;
|
||||
@@ -289,7 +278,7 @@
|
||||
|
||||
@container editor-find (width < 500px) {
|
||||
.find {
|
||||
grid-template-columns: [mode] auto [field] minmax(0, 1fr) [close] auto;
|
||||
grid-template-columns: [mode] auto [field] minmax(0, 1fr);
|
||||
}
|
||||
.findButtons,
|
||||
.replaceButtons {
|
||||
@@ -321,8 +310,7 @@
|
||||
.replaceButtons {
|
||||
grid-column: mode / -1;
|
||||
}
|
||||
.findExpand,
|
||||
.findClose {
|
||||
.findExpand {
|
||||
grid-row: 2;
|
||||
margin-block-start: 0;
|
||||
}
|
||||
|
||||
@@ -710,8 +710,8 @@ export function FindPanel({ target, version, replace, seq, onReplaceShown, onClo
|
||||
onClick={() => setFilterMenu(true)}
|
||||
/>
|
||||
<IconButton ref={moreRef} icon="more" title="More" size="small" onClick={() => setMoreMenu(true)} />
|
||||
<IconButton icon="close" title="Close" shortcut="⎋" size="small" onClick={close} />
|
||||
</div>
|
||||
<IconButton icon="close" title="Close" shortcut="⎋" size="small" className={styles.findClose} onClick={close} />
|
||||
{replace && (
|
||||
<>
|
||||
<div ref={replaceBoxRef} className={styles.replaceField}>
|
||||
|
||||
@@ -53,14 +53,15 @@
|
||||
.childPopup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: min(200px, calc(100vw - 12px));
|
||||
}
|
||||
.list {
|
||||
--nav-child-row: calc(max(16px, 1.2em) + var(--space-0-5));
|
||||
--nav-child-list-padding: 5px;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
max-width: min(480px, calc(100vw - 14px));
|
||||
max-height: min(360px, 62vh);
|
||||
padding: var(--space-1);
|
||||
max-height: min(calc(20 * var(--nav-child-row) + 2 * var(--nav-child-list-padding)), 62vh);
|
||||
padding: var(--nav-child-list-padding);
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
outline: none;
|
||||
@@ -69,10 +70,11 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
height: var(--h-list-row);
|
||||
padding: 0 var(--space-2);
|
||||
height: var(--nav-child-row);
|
||||
padding: 0 var(--space-0-5);
|
||||
border-radius: var(--radius-selection);
|
||||
color: var(--fg);
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rowActive {
|
||||
|
||||
@@ -164,13 +164,16 @@ export const lspTheme = EditorView.theme({
|
||||
justifyContent: "center",
|
||||
},
|
||||
".cm-lsp-completion .cm-completionLabel": {
|
||||
flex: "0 1 auto",
|
||||
flex: "none",
|
||||
maxWidth:
|
||||
"calc(100% - var(--cm-completion-icon) - var(--cm-completion-gap) - var(--cm-completion-detail-gap, 0px) - var(--cm-completion-type-space, 0px))",
|
||||
minWidth: "0",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
},
|
||||
".cm-lsp-completion .cm-completionDetail": {
|
||||
flex: "0 1 auto",
|
||||
// Parameters use the space left by the name and type.
|
||||
flex: "1 1 0px",
|
||||
minWidth: "0",
|
||||
marginLeft: "0",
|
||||
fontStyle: "normal",
|
||||
@@ -178,6 +181,12 @@ export const lspTheme = EditorView.theme({
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
},
|
||||
".cm-lsp-completion li:not(.cm-lsp-option):has(> .cm-completionDetail)": {
|
||||
"--cm-completion-detail-gap": "var(--cm-completion-gap)",
|
||||
},
|
||||
".cm-lsp-completion li:has(> .cm-lsp-type)": {
|
||||
"--cm-completion-type-space": "calc(2 * var(--space-4) + var(--cm-completion-gap))",
|
||||
},
|
||||
".cm-lsp-completion .cm-completionMatchedText": {
|
||||
textDecoration: "none",
|
||||
fontWeight: "var(--fw-code-bold, 700)",
|
||||
@@ -190,7 +199,6 @@ export const lspTheme = EditorView.theme({
|
||||
".cm-lsp-completion .cm-lsp-type": {
|
||||
flex: "0 1 auto",
|
||||
minWidth: "0",
|
||||
maxWidth: "60%",
|
||||
marginLeft: "auto",
|
||||
paddingLeft: "16px",
|
||||
textAlign: "right",
|
||||
|
||||
@@ -410,9 +410,11 @@ describe("Refactor menu actions", () => {
|
||||
});
|
||||
|
||||
describe("requested code action kind", () => {
|
||||
it("asks typescript-language-server for all refactorings, other servers for the kind", () => {
|
||||
it("asks typescript-language-server and clangd for all refactorings, other servers for the kind", () => {
|
||||
expect(requestKind("refactor.extract", "typescript")).toBe("refactor");
|
||||
expect(requestKind("refactor.extract", "javascriptreact")).toBe("refactor");
|
||||
expect(requestKind("refactor.extract", "c")).toBe("refactor");
|
||||
expect(requestKind("refactor.extract", "cpp")).toBe("refactor");
|
||||
expect(requestKind("refactor.extract", "java")).toBe("refactor.extract");
|
||||
expect(requestKind("source.organizeImports", "typescript")).toBe("source.organizeImports");
|
||||
});
|
||||
|
||||
@@ -62,8 +62,20 @@ async function askServer(view: EditorView, signal?: AbortSignal, only?: string[]
|
||||
}
|
||||
}
|
||||
|
||||
/** typescript-language-server returns refactorings only when `only` names `refactor` itself. */
|
||||
const WHOLE_REFACTOR_KIND = new Set(["javascript", "javascriptreact", "typescript", "typescriptreact"]);
|
||||
/**
|
||||
* Servers that return refactorings only when `only` names `refactor` itself: typescript-language-server,
|
||||
* and clangd, whose tweaks are all of kind `refactor`.
|
||||
*/
|
||||
const WHOLE_REFACTOR_KIND = new Set([
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"c",
|
||||
"cpp",
|
||||
"objective-c",
|
||||
"objective-cpp",
|
||||
]);
|
||||
|
||||
/** The code action kind to ask `language`'s server for, to get the refactorings of `kind`. */
|
||||
export function requestKind(kind: string, language: string): string {
|
||||
|
||||
@@ -39,14 +39,18 @@ export type ToggleOption = {
|
||||
[K in keyof ViewOptions]-?: ViewOptions[K] extends boolean ? K : never;
|
||||
}[keyof ViewOptions];
|
||||
|
||||
export const OPTION_LABELS: Array<[ToggleOption, string]> = [
|
||||
const APPEARANCE_OPTIONS: Array<[ToggleOption, string]> = [
|
||||
["showHidden", "Show Hidden Files"],
|
||||
["showExcluded", "Show Excluded Files"],
|
||||
["showMembers", "Show Members"],
|
||||
["showRootPaths", "Show Root Paths"],
|
||||
["horizontalScroll", "Horizontal Scrolling"],
|
||||
["compact", "Compact Middle Packages"],
|
||||
["foldersFirst", "Sort Folders First"],
|
||||
];
|
||||
|
||||
const FOLDERS_FIRST: [ToggleOption, string] = ["foldersFirst", "Sort Folders First"];
|
||||
|
||||
const BEHAVIOR_OPTIONS: Array<[ToggleOption, string]> = [
|
||||
["autoscrollFromSource", "Always Select Opened File"],
|
||||
["autoscrollToSource", "Autoscroll to Source"],
|
||||
["singleClickOpen", "Open Files with Single Click"],
|
||||
@@ -54,8 +58,7 @@ export const OPTION_LABELS: Array<[ToggleOption, string]> = [
|
||||
["previewTab", "Enable Preview Tab"],
|
||||
];
|
||||
|
||||
/** The first entries of OPTION_LABELS are Appearance options, the rest Behavior. */
|
||||
const APPEARANCE_OPTIONS = 7;
|
||||
export const OPTION_LABELS = [...APPEARANCE_OPTIONS, FOLDERS_FIRST, ...BEHAVIOR_OPTIONS];
|
||||
|
||||
/** Header controls of the Project tool window (IDEA: Locate, Expand/Collapse All). */
|
||||
export function ProjectHeaderActions() {
|
||||
@@ -78,35 +81,46 @@ export function ProjectHeaderActions() {
|
||||
);
|
||||
}
|
||||
|
||||
export const SORT_LABELS: Array<[SortKey, string]> = [
|
||||
["name", "Sort by Name"],
|
||||
["type", "Sort by Type"],
|
||||
["modified", "Sort by Modification Time"],
|
||||
export const SORT_LABELS: Array<[key: SortKey, actionLabel: string, menuLabel: string]> = [
|
||||
["name", "Sort by Name", "Name"],
|
||||
["type", "Sort by Type", "Type"],
|
||||
["modified", "Sort by Modification Time", "Modification Time"],
|
||||
];
|
||||
|
||||
/** View options in the header's "⋮" menu (IDEA: Project › Options › Appearance / Behavior). */
|
||||
/** Project view options in the header's "⋮" menu. */
|
||||
export function useProjectHeaderMenu(): MenuItem[] {
|
||||
const options = useProjectTree((s) => s.options);
|
||||
const unity = useProjectTree((s) => s.mode === "unity");
|
||||
return [
|
||||
{ kind: "header", label: "Appearance" },
|
||||
...(unity
|
||||
? [
|
||||
option("showUnityMeta", "Show Meta Files", options),
|
||||
option("showUnityGenerated", "Show Generated Files", options),
|
||||
]
|
||||
: []),
|
||||
...OPTION_LABELS.slice(0, APPEARANCE_OPTIONS).map(([key, label]) => option(key, label, options)),
|
||||
{ kind: "separator" },
|
||||
...SORT_LABELS.map(([sortBy, label]): MenuItem => ({
|
||||
id: `sort.${sortBy}`,
|
||||
label,
|
||||
checked: options.sortBy === sortBy,
|
||||
run: () => setViewOption("sortBy", sortBy),
|
||||
})),
|
||||
{ kind: "separator" },
|
||||
{ kind: "header", label: "Behavior" },
|
||||
...OPTION_LABELS.slice(APPEARANCE_OPTIONS).map(([key, label]) => option(key, label, options)),
|
||||
{
|
||||
label: "Behavior",
|
||||
submenu: BEHAVIOR_OPTIONS.map(([key, label]) => option(key, label, options)),
|
||||
},
|
||||
{
|
||||
label: "Appearance",
|
||||
submenu: [
|
||||
...(unity
|
||||
? [
|
||||
option("showUnityMeta", "Show Meta Files", options),
|
||||
option("showUnityGenerated", "Show Generated Files", options),
|
||||
]
|
||||
: []),
|
||||
...APPEARANCE_OPTIONS.map(([key, label]) => option(key, label, options)),
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Sort By",
|
||||
submenu: [
|
||||
...SORT_LABELS.map(([sortBy, , label]): MenuItem => ({
|
||||
id: `sort.${sortBy}`,
|
||||
label,
|
||||
checked: options.sortBy === sortBy,
|
||||
run: () => setViewOption("sortBy", sortBy),
|
||||
})),
|
||||
{ kind: "separator" },
|
||||
option(...FOLDERS_FIRST, options),
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -507,7 +507,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
{config.kind === "tomcat" ? (
|
||||
<TomcatSettings config={config} onChange={onChange} />
|
||||
) : (
|
||||
<>
|
||||
<div className={styles.formSettings}>
|
||||
{!noProcess && (
|
||||
<Field
|
||||
label="Run on"
|
||||
@@ -860,7 +860,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -665,22 +665,39 @@
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.configFields {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(40%) minmax(0, 1fr);
|
||||
grid-template-rows: [notice] auto [header] auto [options] minmax(0, 1fr);
|
||||
column-gap: var(--space-3);
|
||||
row-gap: var(--space-2);
|
||||
align-content: start;
|
||||
min-width: 0;
|
||||
}
|
||||
.configFields > * {
|
||||
.configFields > *,
|
||||
.formSettings > * {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
}
|
||||
.configFields:not(.configFieldsTomcat) > .field,
|
||||
.configFields > .notice {
|
||||
grid-row: notice;
|
||||
}
|
||||
.configFields:not(.configFieldsTomcat) > .notice,
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader {
|
||||
margin-bottom: var(--space-2);
|
||||
}
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader,
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader > .field {
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader > .field,
|
||||
.formSettings > .field {
|
||||
grid-template-columns: subgrid;
|
||||
}
|
||||
.formSettings {
|
||||
display: grid;
|
||||
grid-row: options;
|
||||
grid-template-columns: subgrid;
|
||||
row-gap: var(--space-2);
|
||||
align-content: start;
|
||||
overflow: auto;
|
||||
}
|
||||
.formHeader > .field {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
@@ -688,8 +705,6 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
.configFieldsTomcat {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
@@ -793,6 +808,7 @@
|
||||
}
|
||||
.formHeader {
|
||||
display: grid;
|
||||
grid-row: header;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
|
||||
@@ -496,7 +496,17 @@
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
.detailsBar {
|
||||
height: auto;
|
||||
min-height: 32px;
|
||||
flex-wrap: wrap;
|
||||
padding-block: var(--space-0-5);
|
||||
}
|
||||
.detailsCount {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding-left: 4px;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-ui);
|
||||
|
||||
@@ -176,21 +176,21 @@ export function CommitDetails({ commits, fileHistory = false }: { commits: Commi
|
||||
const treeRef = useRef<TreeHandle>(null);
|
||||
const [diffToReveal, setDiffToReveal] = useState<{ key: string } | null>(null);
|
||||
const syncingDiff = useRef(false);
|
||||
const affectedPaths = filters.paths?.length ? filters.paths : filters.path;
|
||||
const changes = useMemo(() => {
|
||||
const changes = files ?? [];
|
||||
const paths = filters.paths?.length ? filters.paths : filters.path ? [filters.path] : [];
|
||||
return onlyAffected && paths.length
|
||||
? changes.filter((c) =>
|
||||
paths.some((p) => {
|
||||
const matches = (rel: string) => {
|
||||
const abs = absolutePath(rel, c.repo);
|
||||
return abs === p || abs.startsWith(`${p}/`) || (!many && commit?.historyPath === rel);
|
||||
};
|
||||
return matches(c.path) || (c.oldPath != null && matches(c.oldPath));
|
||||
}),
|
||||
)
|
||||
: changes;
|
||||
}, [files, commit, many, filters.path, filters.paths, onlyAffected]);
|
||||
if (!onlyAffected || !affectedPaths) return changes;
|
||||
const paths = typeof affectedPaths === "string" ? [affectedPaths] : affectedPaths;
|
||||
return changes.filter((c) =>
|
||||
paths.some((p) => {
|
||||
const matches = (rel: string) => {
|
||||
const abs = absolutePath(rel, c.repo);
|
||||
return abs === p || abs.startsWith(`${p}/`) || (!many && commit?.historyPath === rel);
|
||||
};
|
||||
return matches(c.path) || (c.oldPath != null && matches(c.oldPath));
|
||||
}),
|
||||
);
|
||||
}, [files, commit, many, affectedPaths, onlyAffected]);
|
||||
const lineTotals = useMemo(() => {
|
||||
if (!showLineStats || !changes.length) return null;
|
||||
if (changes.some((f) => f.added === undefined || f.removed === undefined)) return null;
|
||||
@@ -289,10 +289,12 @@ export function CommitDetails({ commits, fileHistory = false }: { commits: Commi
|
||||
{ kind: "header", label: "Group By" },
|
||||
{ kind: "action", action: "vcs.log.changes.groupByDirectory" },
|
||||
{ kind: "separator" },
|
||||
{ kind: "action", action: "vcs.log.changes.diffPreview" },
|
||||
toggle("Show Only Affected Changes", logOptions(), "showOnlyAffected"),
|
||||
{ kind: "header", label: "Show" },
|
||||
toggle("Show lines added and deleted", logOptions(), "showLineStats"),
|
||||
toggle("Show Changes from Parents", logOptions(), "changesFromParents"),
|
||||
{ kind: "separator" },
|
||||
{ kind: "header", label: "Layout" },
|
||||
{ kind: "action", action: "vcs.log.changes.diffPreview" },
|
||||
{
|
||||
label: "Diff Preview Location",
|
||||
submenu: (["editor", "right", "bottom"] as const).map((location) => ({
|
||||
@@ -368,6 +370,9 @@ export function CommitDetails({ commits, fileHistory = false }: { commits: Commi
|
||||
actionArg={chosenChanges}
|
||||
disabled={readOnly || !chosenChanges.length || new Set(chosenChanges.map((c) => c.repo)).size > 1}
|
||||
/>
|
||||
{affectedPaths && (
|
||||
<IconButton icon="folder" action="vcs.log.changes.showOnlyAffected" size="small" pressed={onlyAffected} />
|
||||
)}
|
||||
<IconButton icon="eye" title="View Options" size="small" aria-haspopup="menu" onClick={openViewOptions} />
|
||||
{!many && fromParents && commit.parents.length > 1 && (
|
||||
<button
|
||||
|
||||
@@ -253,6 +253,15 @@ export function registerLogPaneActions(): () => void {
|
||||
toggled: () => logOptions().groupByDirectory,
|
||||
run: () => updateLogOptions({ groupByDirectory: !logOptions().groupByDirectory }),
|
||||
},
|
||||
{
|
||||
id: "vcs.log.changes.showOnlyAffected",
|
||||
title: "Show Only Affected Changes",
|
||||
category: "Git Log",
|
||||
when: LOG,
|
||||
hidden: true,
|
||||
toggled: () => logOptions().showOnlyAffected,
|
||||
run: () => updateLogOptions({ showOnlyAffected: !logOptions().showOnlyAffected }),
|
||||
},
|
||||
{
|
||||
id: "vcs.log.changes.diffPreview",
|
||||
title: "Show Diff Preview",
|
||||
|
||||
@@ -1031,6 +1031,8 @@
|
||||
"Resolving reference…": "Resolving reference…",
|
||||
"Insert imports on paste": "Insert imports on paste",
|
||||
"Path with line number": "Path with line number",
|
||||
"Absolute Path with line number": "Absolute Path with line number",
|
||||
"Copy Absolute Path with Line Number": "Copy Absolute Path with Line Number",
|
||||
"Clipboard history": "Clipboard history",
|
||||
"From Clipboard": "From Clipboard",
|
||||
"Selection from {file}": "Selection from {file}",
|
||||
@@ -1527,6 +1529,11 @@
|
||||
"Disable plugin": "Disable plugin",
|
||||
"{names} need {name} and stop while it is disabled. Disable it anyway?": "{names} need {name} and stop while it is disabled. Disable it anyway?",
|
||||
"{names} needs {name} and stops while it is disabled. Disable it anyway?": "{names} needs {name} and stops while it is disabled. Disable it anyway?",
|
||||
"Appearance": "Appearance",
|
||||
"Behavior": "Behavior",
|
||||
"Sort By": "Sort By",
|
||||
"Type": "Type",
|
||||
"Modification Time": "Modification Time",
|
||||
"Show Root Paths": "Show Root Paths",
|
||||
"Workspace": "Workspace",
|
||||
"Disable Server": "Disable Server",
|
||||
@@ -3031,5 +3038,7 @@
|
||||
"ID:": "ID:",
|
||||
"Homepage:": "Homepage:",
|
||||
"Mail:": "Mail:",
|
||||
"A folder with this name already exists and is not empty": "A folder with this name already exists and is not empty"
|
||||
"A folder with this name already exists and is not empty": "A folder with this name already exists and is not empty",
|
||||
"Show Only Affected Changes": "Show Only Affected Changes",
|
||||
"Layout": "Layout"
|
||||
}
|
||||
@@ -949,6 +949,8 @@
|
||||
"Resolving reference…": "Başvuru çözümleniyor…",
|
||||
"Insert imports on paste": "Yapıştırırken içe aktarmaları ekle",
|
||||
"Path with line number": "Satır numaralı yol",
|
||||
"Absolute Path with line number": "Satır numaralı mutlak yol",
|
||||
"Copy Absolute Path with Line Number": "Mutlak Yolu Satır Numarasıyla Kopyala",
|
||||
"Clipboard history": "Pano geçmişi",
|
||||
"Copy Path with Line Number": "Yolu Satır Numarasıyla Kopyala",
|
||||
"1 line": "1 satır",
|
||||
|
||||
@@ -7412,6 +7412,8 @@
|
||||
"Add Imports": "新增匯入",
|
||||
"Copy Path with Line Number": "複製帶行號的路徑",
|
||||
"Path with line number": "帶行號的路徑",
|
||||
"Absolute Path with line number": "帶行號的絕對路徑",
|
||||
"Copy Absolute Path with Line Number": "複製帶行號的絕對路徑",
|
||||
"1 line": "1 行",
|
||||
"Add Imports on Paste": "貼上時新增匯入",
|
||||
"(whitespace)": "(空白)",
|
||||
|
||||
@@ -5904,6 +5904,7 @@
|
||||
"No live templates to surround with": "没有可用于包围的实时模板",
|
||||
"Sort by Name": "按名称排序",
|
||||
"Sort by Type": "按类型排序",
|
||||
"Modification Time": "修改时间",
|
||||
"Sort by Modification Time": "按修改时间排序",
|
||||
"Add Mouse Shortcut": "添加鼠标快捷键",
|
||||
"Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "按住 Ctrl、Alt 或 Command 在此点击,或使用鼠标中键或侧键",
|
||||
@@ -7498,6 +7499,8 @@
|
||||
"Add Imports": "添加导入",
|
||||
"Copy Path with Line Number": "复制带行号的路径",
|
||||
"Path with line number": "带行号的路径",
|
||||
"Absolute Path with line number": "带行号的绝对路径",
|
||||
"Copy Absolute Path with Line Number": "复制带行号的绝对路径",
|
||||
"1 line": "1 行",
|
||||
"Add Imports on Paste": "粘贴时添加导入",
|
||||
"(whitespace)": "(空白)",
|
||||
@@ -9354,5 +9357,7 @@
|
||||
"Signed by:": "签名者:",
|
||||
"ID:": "ID:",
|
||||
"Homepage:": "主页:",
|
||||
"Mail:": "邮件:"
|
||||
"Mail:": "邮件:",
|
||||
"Show Only Affected Changes": "仅显示受影响的变更",
|
||||
"Layout": "布局"
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача