Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 869b8a4f43 fix(vcs): anchor the Git Log path editor 2026-11-23 11:26:57 +08:00
l0ng-ai fc7fa85850 fix(maven): give plugin names priority in the tree (#5288)
Maven plugin rows use the plugin prefix as the primary label and show the coordinates in muted text. The coordinates truncate independently in narrow docks and can be read in full from their tooltip.
2026-11-23 10:49:33 +08:00
8 змінених файлів з 353 додано та 48 видалено

No files matched your search

+93
Переглянути файл
@@ -2,6 +2,7 @@
* Git Log toolbar buttons close their popup when clicked again, as in IDEA, instead of
* keeping it open (Branch) or replaying its opening (the menus). Git is stubbed at the IPC layer.
*/
import type { Page } from "@playwright/test";
import { expect, stubDesktop, test } from "./fixtures";
test.beforeEach(async ({ workbench: page }) => {
@@ -60,6 +61,98 @@ test.beforeEach(async ({ workbench: page }) => {
await expect(page.getByRole("listbox", { name: "Commits" }).getByRole("option").first()).toBeVisible();
});
async function openLogPathEditor(page: Page) {
const toolbar = page.getByRole("toolbar", { name: "Log filters", exact: true });
const filter = toolbar.getByRole("button", { name: /^Paths(:|$)/ });
const overflow = toolbar.getByRole("button", { name: "More Filters", exact: true });
const visible = await filter.isVisible();
const anchor = visible ? filter : overflow;
await anchor.click();
if (!visible) await page.getByRole("menuitem", { name: /^Paths(:|$)/ }).click();
await page.getByRole("menuitem", { name: "Select…", exact: true }).click();
const editor = page.getByRole("dialog", { name: "Filter by Paths", exact: true });
await expect(editor.getByRole("textbox", { name: "Paths", exact: true })).toBeFocused();
return { anchor, editor };
}
test("the Git Log path editor anchors to its filter and wraps long paths", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1220, height: 760 });
await page.evaluate(async () => {
const logPath = "/src/features/vcs/logStore.ts";
const optionsPath = "/src/features/vcs/logOptions.ts";
const { setLogFilters } = await import(/* @vite-ignore */ logPath);
const { setLogOptions } = await import(/* @vite-ignore */ optionsPath);
setLogOptions({ showBranches: false, showDetails: false });
setLogFilters({
paths: ["/dev/acme-api/src/" + "settlement-".repeat(12) + "report.ts", "/dev/acme-api/docs/guide.md"],
});
});
const { anchor, editor } = await openLogPathEditor(page);
const input = editor.getByRole("textbox", { name: "Paths", exact: true });
const popupBox = (await editor.boundingBox())!;
const anchorBox = (await anchor.boundingBox())!;
const gap = Math.min(
Math.abs(popupBox.y - anchorBox.y - anchorBox.height),
Math.abs(anchorBox.y - popupBox.y - popupBox.height),
);
expect(gap).toBeLessThanOrEqual(6);
expect((await input.boundingBox())!.height).toBeGreaterThan(120);
expect(await input.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await expect(editor.getByText("One path per line", { exact: true })).toBeVisible();
const grip = (await editor.getByRole("separator", { name: "Resize", exact: true }).boundingBox())!;
const x = grip.x + grip.width / 2;
const y = grip.y + grip.height / 2;
await page.mouse.move(x, y);
await page.mouse.down();
await page.mouse.move(x, y + 34, { steps: 4 });
await page.mouse.up();
await expect.poll(async () => (await editor.boundingBox())!.height).toBeGreaterThan(popupBox.height + 20);
await input.fill("src\ndocs/draft.md");
await page.setViewportSize({ width: 460, height: 550 });
const overflow = page.getByRole("toolbar", { name: "Log filters" }).getByRole("button", { name: "More Filters" });
await expect(overflow).toBeVisible();
await expect(input).toHaveValue("src\ndocs/draft.md");
await expect(editor).toBeInViewport({ ratio: 0.98 });
await input.press("Escape");
await expect(editor).toHaveCount(0);
});
test("the narrow Git Log path editor applies with the primary shortcut and discards outside clicks", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 460, height: 550 });
const { editor } = await openLogPathEditor(page);
const input = editor.getByRole("textbox", { name: "Paths", exact: true });
await expect(editor.getByRole("separator", { name: "Resize", exact: true })).toBeVisible();
await expect(editor.getByRole("button", { name: "OK", exact: true })).toBeInViewport({ ratio: 0.98 });
const modifier = await page.evaluate(async () => {
const module = "/src/platform/keymap.ts";
const { isMacHost } = await import(/* @vite-ignore */ module);
return isMacHost() ? "Meta" : "Control";
});
await input.fill("src");
await input.press("End");
await input.press("Enter");
await expect(input).toHaveValue("src\n");
await input.fill("../outside");
await input.press(`${modifier}+Enter`);
await expect(editor.getByRole("alert")).toHaveText("Choose a path inside a repository.");
await input.fill("src\ndocs/guide.md\nsrc");
await input.press(`${modifier}+Enter`);
await expect(editor).toHaveCount(0);
const reopened = await openLogPathEditor(page);
await expect(input).toHaveValue("src\ndocs/guide.md");
await input.fill("discarded");
await page.mouse.click(4, 4);
await expect(reopened.editor).toHaveCount(0);
const again = await openLogPathEditor(page);
await expect(input).toHaveValue("src\ndocs/guide.md");
await again.anchor.click();
await expect(again.editor).toHaveCount(0);
});
test("Git Log separates commit message typography from compact metadata", async ({ workbench: page }) => {
await page.setViewportSize({ width: 860, height: 720 });
await page.evaluate(() => {
+74
Переглянути файл
@@ -0,0 +1,74 @@
import type { MavenModel } from "../src/platform/ipc";
import { expect, stubDesktop, test } from "./fixtures";
const maven: MavenModel = {
projects: [
{
pom: "pom.xml",
dir: "",
groupId: "dev.acme",
artifactId: "billing",
version: "1.0.0",
packaging: "jar",
displayName: "Billing",
parent: null,
modules: [],
aggregated: false,
plugins: [
{
groupId: "org.apache.maven.plugins",
artifactId: "maven-surefire-plugin",
version: "3.2.5",
prefix: "surefire",
goals: ["test"],
},
],
dependencies: [],
profiles: [],
javaVersion: 21,
command: "mvn",
options: [],
env: {},
},
],
profiles: [],
syncedAt: 1,
stale: false,
syncError: null,
};
test("Maven plugin rows give the name priority over coordinates in narrow docks", async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(async (maven) => {
window.__ipc.handlers.build_model = () => ({ maven, gradle: [] });
const buildModule = "/src/features/build-tools/store.ts";
const { loadModel, setExpanded } = await import(/* @vite-ignore */ buildModule);
await loadModel();
setExpanded("maven", new Set(["mvn:pom.xml", "mvn:pom.xml:plugins"]));
const dockModule = "/src/workbench/toolwindows/store.ts";
const { showToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ dockModule);
showToolWindow("maven", true);
setToolWindowSize("right", 190);
}, maven);
const tree = page.getByRole("tree", { name: "Maven projects" });
const coordinates = "(org.apache.maven.plugins:maven-surefire-plugin:3.2.5)";
const plugin = tree.getByRole("treeitem", { name: `surefire ${coordinates}`, exact: true });
const name = plugin.getByText("surefire", { exact: true });
const metadata = plugin.getByText(coordinates, { exact: true });
await expect(name).toBeVisible();
await expect(metadata).toHaveAttribute("title", coordinates);
const fit = (el: Element) => {
const range = document.createRange();
range.selectNodeContents(el);
return range.getBoundingClientRect().width <= el.getBoundingClientRect().width;
};
expect(await name.evaluate(fit)).toBe(true);
expect(await metadata.evaluate(fit)).toBe(false);
expect(await metadata.evaluate((el) => getComputedStyle(el).color)).not.toBe(
await name.evaluate((el) => getComputedStyle(el).color),
);
await plugin.locator("[data-tree-toggle]").click();
await expect(tree.getByRole("treeitem", { name: "surefire:test", exact: true })).toBeVisible();
});
+18 -3
Переглянути файл
@@ -31,6 +31,7 @@ import {
mavenRoots,
nodeIcon,
nodeLabel,
pluginCoordinates,
profileChecked,
withGradleOptions,
gradleHasTestTask,
@@ -310,6 +311,8 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
</span>
);
}
const plugin = node.kind === "plugin" ? node.plugin : null;
const coordinates = plugin && `(${pluginCoordinates(plugin)})`;
const detail =
node.kind === "profiles" && node.projectRoot
? node.projectRoot.split("/").pop()
@@ -321,12 +324,24 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
const skipped =
(mavenSkipTests && node.kind === "phase" && node.phase === "test") ||
(gradleSkipTests && node.kind === "task" && node.task.name === "test");
const label = (
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
{plugin?.prefix ?? nodeLabel(node)}
</span>
);
return (
<span className={styles.row}>
<Icon name={nodeIcon(node)} size={16} className={styles.icon} />
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
{nodeLabel(node)}
</span>
{coordinates ? (
<span className={styles.pluginText}>
{label}
<span className={styles.detail} title={coordinates}>
{coordinates}
</span>
</span>
) : (
label
)}
{detail && <span className={styles.detail}>{detail}</span>}
</span>
);
+12
Переглянути файл
@@ -96,6 +96,18 @@
overflow: hidden;
text-overflow: ellipsis;
}
.pluginText {
display: flex;
align-items: center;
gap: var(--space-1-5);
min-width: 0;
overflow: hidden;
}
.pluginText > .label {
flex: none;
min-width: 0;
max-width: 100%;
}
.profile {
min-width: 0;
}
+3 -3
Переглянути файл
@@ -99,8 +99,8 @@ export function dependencyLabel(d: MavenDependency): string {
return parts.join(":");
}
export function pluginLabel(p: MavenPlugin): string {
return `${p.prefix} (${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""})`;
export function pluginCoordinates(p: MavenPlugin): string {
return `${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""}`;
}
/** Profile choices in different workspace members are independent. */
@@ -363,7 +363,7 @@ export function nodeLabel(node: BuildNode): string {
case "plugins":
return tx("Plugins");
case "plugin":
return pluginLabel(node.plugin);
return `${node.plugin.prefix} (${pluginCoordinates(node.plugin)})`;
case "goal":
return `${node.plugin.prefix}:${node.goal}`;
case "dependencies":
+53
Переглянути файл
@@ -68,3 +68,56 @@
overflow-wrap: anywhere;
color: var(--danger);
}
.editor {
display: flex;
flex-direction: column;
overflow: hidden;
}
.pathInput {
flex: 1;
min-height: 0;
width: 100%;
padding: var(--space-2) var(--space-3);
resize: none;
border: 0;
outline: none;
background: var(--bg-editor);
color: var(--fg-editor);
font-family: var(--font-mono);
font-size: var(--fs-code);
line-height: var(--lh-code);
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.pathInput:focus-visible {
box-shadow: inset 0 0 0 1px var(--focus-ring);
}
.editorError {
flex: none;
padding: var(--space-1) var(--space-2);
color: var(--danger);
}
.editorFooter {
flex: none;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: var(--space-1) var(--space-2);
padding: var(--space-1) var(--space-2);
border-top: 1px solid var(--border-popup);
color: var(--fg-secondary);
font-size: var(--fs-small);
}
.apply {
display: inline-flex;
align-items: center;
gap: var(--space-2);
margin-inline-start: auto;
}
+60 -35
Переглянути файл
@@ -1,11 +1,13 @@
import { useState } from "react";
import { Checkbox, Dialog, Icon, SearchField, Tree, fileIconName } from "@/ui";
import { useId, useState } from "react";
import { Button, Checkbox, Dialog, Icon, Popup, T, Tree, fileIconName } from "@/ui";
import { projectFs } from "@/features/project-tree/fs";
import { openDialog } from "./dialogs";
import { dirName, relTo, stripSlash } from "./model";
import { repoName, repoOf } from "./store";
import { call, commands } from "@/platform/ipc";
import { tx } from "@/platform/i18n";
import { isImeKey } from "@/platform/ime";
import { formatBinding, hasPrimaryModifier, isMacHost } from "@/platform/keymap";
import { ipcPath, isSameOrInside } from "@/platform/paths";
import styles from "./PathFilterDialog.module.css";
@@ -31,42 +33,33 @@ export function chooseLogPaths(roots: string[], initial: string[], readOnly = fa
});
}
export function editLogPaths(roots: string[], initial: string[]): Promise<string[] | null> {
function commonRoot(roots: string[]): string | undefined {
let base = roots[0];
while (base && !roots.every((root) => isSameOrInside(root, base!))) {
const parent = dirName(base);
base = parent || (base.startsWith("/") && base !== "/" ? "/" : undefined);
}
return new Promise((resolve) => {
const close = openDialog(() => (
<LogPathsEditor
roots={roots}
initial={initial}
base={base}
onDone={(value) => {
close();
resolve(value);
}}
/>
));
});
return base;
}
function LogPathsEditor({
export function LogPathsEditor({
anchor,
roots,
initial,
base,
onDone,
}: {
anchor: HTMLElement;
roots: string[];
initial: string[];
base?: string;
onDone: (value: string[] | null) => void;
}) {
const [base] = useState(() => commonRoot(roots));
const [text, setText] = useState(() =>
initial.map((path) => (base ? (path === base ? "." : relTo(stripSlash(base), path)) : path)).join("\n"),
);
const [error, setError] = useState(false);
const hint = useId();
const shortcut = formatBinding(isMacHost() ? "Meta+Enter" : "Ctrl+Enter");
const apply = () => {
const paths = text
.split("\n")
@@ -88,30 +81,62 @@ function LogPathsEditor({
onDone([...new Set(paths)]);
};
return (
<Dialog
<Popup
open
title="Filter by Paths"
width={560}
anchor={anchor}
aria-label={tx("Filter by Paths")}
className={styles.editor}
initialSize={{ w: 432, h: 200 }}
resizable="both"
minWidth={200}
minHeight={110}
trapFocus
onClose={() => onDone(null)}
buttons={[
{ label: "OK", role: "default", onClick: apply },
{ label: "Cancel", role: "cancel" },
]}
>
<SearchField
<textarea
data-autofocus
multiline
leadingIcon={null}
className={styles.pathInput}
spellCheck={false}
value={text}
onChange={(value) => {
setText(value);
onChange={(event) => {
setText(event.target.value);
setError(false);
}}
aria-label="Paths"
placeholder="One path per line"
onKeyDown={(event) => {
if (
event.key !== "Enter" ||
!hasPrimaryModifier(event) ||
event.shiftKey ||
event.altKey ||
isImeKey(event.nativeEvent)
) {
return;
}
event.preventDefault();
event.stopPropagation();
apply();
}}
aria-label={tx("Paths")}
aria-describedby={hint}
aria-invalid={error || undefined}
/>
{error && <div role="alert">{tx("Choose a path inside a repository.")}</div>}
</Dialog>
{error && (
<div className={styles.editorError} role="alert">
<T>Choose a path inside a repository.</T>
</div>
)}
<div className={styles.editorFooter}>
<span id={hint}>
<T>One path per line</T>
</span>
<span className={styles.apply}>
<kbd>{shortcut}</kbd>
<Button onClick={apply} size="small" variant="primary">
OK
</Button>
</span>
</div>
</Popup>
);
}
+40 -7
Переглянути файл
@@ -27,7 +27,7 @@ import {
} from "../logStore";
import { relTo } from "../model";
import { branchesByRepo } from "../multiRoot";
import { chooseLogPaths, editLogPaths } from "../PathFilterDialog";
import { LogPathsEditor, chooseLogPaths } from "../PathFilterDialog";
import { openExternalLog } from "../RevisionBrowser";
import { currentRepo, repoName, useVcs } from "../store";
import { useDropdownMenu, useLogRepositories, useReadOnlyLog } from "./logHooks";
@@ -51,13 +51,21 @@ interface LogFilter {
onClear: () => void;
}
function FilterButton({ label, value, onOpen, onClear, hidden }: LogFilter & { hidden?: boolean }) {
function FilterButton({
label,
value,
onOpen,
onClear,
hidden,
triggerRef,
}: LogFilter & { hidden?: boolean; triggerRef?: (button: HTMLButtonElement | null) => void }) {
return (
<span
className={clsx(styles.filterButton, value && styles.filterActive, hidden && styles.filterHidden)}
inert={hidden}
>
<button
ref={triggerRef}
type="button"
className={styles.filterMain}
onClick={(e) => onOpen(e.currentTarget)}
@@ -125,6 +133,11 @@ export function FilterBar({ fileHistory = false }: { fileHistory?: boolean }) {
}, [repositories, filters.repositories, version, logGeneration]);
const [text, setText] = useState(filters.text);
const [branchAnchor, setBranchAnchor] = useState<HTMLElement | null>(null);
const [pathEditor, setPathEditor] = useState<{ roots: string[]; initial: string[] } | null>(null);
const [pathsTrigger, setPathsTrigger] = useState<HTMLButtonElement | null>(null);
const [overflowTrigger, setOverflowTrigger] = useState<HTMLButtonElement | null>(null);
const pathEditorAnchor = overflowTrigger ?? pathsTrigger;
if (!active && pathEditor) setPathEditor(null);
const [menuBelow, dropdown] = useDropdownMenu();
// Filters that do not fit move behind a chevron, like a toolbar's overflow.
const groupRef = useRef<HTMLSpanElement>(null);
@@ -246,7 +259,13 @@ export function FilterBar({ fileHistory = false }: { fileHistory?: boolean }) {
paths: [],
repositories: selected.length === repositories.length ? [] : selected,
});
const closePathEditorAt = (anchor: HTMLElement) => {
if (!pathEditor || pathEditorAnchor !== anchor) return false;
setPathEditor(null);
return true;
};
const openPaths = (anchor: HTMLElement) => {
if (closePathEditorAt(anchor)) return;
const modifier = isMacHost() ? "⌘" : "Ctrl";
const repositoryItems: MenuItem[] =
repositories.length > 1
@@ -292,10 +311,7 @@ export function FilterBar({ fileHistory = false }: { fileHistory?: boolean }) {
menuBelow(anchor, [
{
label: "Select…",
run: async () => {
const selected = await editLogPaths(pathRoots, paths);
if (selected) selectPaths(selected);
},
run: () => setPathEditor({ roots: pathRoots, initial: paths }),
},
{
label: "Select in Tree…",
@@ -373,17 +389,24 @@ export function FilterBar({ fileHistory = false }: { fileHistory?: boolean }) {
/>
<span ref={groupRef} className={styles.filterGroup}>
{logFilters.map((f, i) => (
<FilterButton key={f.label} {...f} hidden={i >= hiddenFrom} />
<FilterButton
key={f.label}
{...f}
hidden={i >= hiddenFrom}
triggerRef={f.label === "Paths" ? setPathsTrigger : undefined}
/>
))}
</span>
{hiddenFrom < logFilters.length && (
<IconButton
ref={setOverflowTrigger}
icon="chevron-right"
title="More Filters"
size="small"
aria-haspopup="menu"
onClick={(e) => {
const anchor = e.currentTarget;
if (closePathEditorAt(anchor)) return;
menuBelow(
anchor,
logFilters.slice(hiddenFrom).map((f) => ({
@@ -396,6 +419,16 @@ export function FilterBar({ fileHistory = false }: { fileHistory?: boolean }) {
)}
</div>
{dropdown}
{pathEditor && pathEditorAnchor && (
<LogPathsEditor
{...pathEditor}
anchor={pathEditorAnchor}
onDone={(paths) => {
setPathEditor(null);
if (paths) selectPaths(paths);
}}
/>
)}
{branchAnchor && (
<BranchFilterPopup
anchor={branchAnchor}