дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 01:57:13 +02:00
Порівняти коміти
12
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
1e8138fa25 | ||
|
|
e2ca1ca4e0 | ||
|
|
b02f212d3e | ||
|
|
ca7f26f484 | ||
|
|
bf4fff8fcf | ||
|
|
3cbe327a6a | ||
|
|
0311297886 | ||
|
|
a711c991b6 | ||
|
|
698cad2b3f | ||
|
|
581c64f544 | ||
|
|
77d6d81f8a | ||
|
|
ea62941bc6 |
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
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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())!;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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(" ")];
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -3038,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"
|
||||
}
|
||||
@@ -9357,5 +9357,7 @@
|
||||
"Signed by:": "签名者:",
|
||||
"ID:": "ID:",
|
||||
"Homepage:": "主页:",
|
||||
"Mail:": "邮件:"
|
||||
"Mail:": "邮件:",
|
||||
"Show Only Affected Changes": "仅显示受影响的变更",
|
||||
"Layout": "布局"
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача