fix(search): use 16px file icons and spinners in Find and Usages (#2493)

Find results and Show Usages use the native 16px file/folder icons, and the four search indicators share the 16px eight-spoke animation, replacing 12/14px overrides; the preview and rerun controls get their proper icons.
This commit is contained in:
l0ng-ai
2026-11-10 23:41:29 +08:00
committed by GitHub
parent 839123caf2
commit 7594a98e8c
8 changed files with 187 additions and 9 deletions
+163
View File
@@ -0,0 +1,163 @@
import type { Locator } from "@playwright/test";
import { expect, stubDesktop, test } from "./fixtures";
async function checkSize(icon: Locator, size = 16) {
const dimensions = await icon.evaluate((node) => {
const style = getComputedStyle(node);
return [Number.parseFloat(style.width), Number.parseFloat(style.height)];
});
expect.soft(dimensions).toEqual([size, size]);
}
for (const theme of ["light", "dark"] as const) {
for (const width of [160, 320]) {
test(`Find and Usages icons align in ${theme} at ${width}px`, async ({ workbench: page }) => {
await page.evaluate(async (theme) => {
const themePath = "/src/workbench/theme.ts";
const findPath = "/src/features/search/find/windowStore.ts";
const { previewTheme } = await import(themePath);
const { openInFindWindow, useFindViewOptions } = await import(findPath);
previewTheme(theme);
useFindViewOptions.setState({ groupByDirectory: true });
let finish: (() => void) | undefined;
let request = 0;
openInFindWindow(
{ pattern: "build", caseSensitive: false, wholeWord: false, isRegex: false, context: "any" },
"build",
{
deps: {
validate: async () => {},
nextRequestId: () => ++request,
cancel: () => finish?.(),
start: async (_id: number, _query: unknown, onFile: (file: object) => void) => {
onFile({
path: "/dev/acme-api/build.gradle.kts",
relPath: "build.gradle.kts",
matches: [{ line: 0, text: "build", textOffset: 0, ranges: [[0, 5]] }],
});
await new Promise<void>((resolve) => (finish = resolve));
return { files: 1, matches: 1, limitHit: false, cancelled: true, elapsedMs: 1 };
},
},
},
);
}, theme);
const find = page.getByRole("region", { name: "Find", exact: true });
const tree = find.getByRole("tree", { name: "Find results" });
await expect(tree.getByText("build.gradle.kts", { exact: true })).toBeVisible();
const panel = tree.locator("..");
const bounds = (await panel.boundingBox())!;
const handle = (await find.getByRole("separator").boundingBox())!;
const y = handle.y + handle.height / 2;
await page.mouse.move(handle.x + handle.width / 2, y);
await page.mouse.down();
await page.mouse.move(bounds.x + width, y, { steps: 4 });
await page.mouse.up();
await expect.poll(async () => Math.abs((await panel.boundingBox())!.width - width)).toBeLessThan(2);
const fileIcon = tree
.getByRole("treeitem")
.filter({ has: page.getByText("build.gradle.kts", { exact: true }) })
.locator("svg")
.last();
const directoryIcon = tree
.getByRole("treeitem")
.filter({ has: page.getByText("/", { exact: true }) })
.locator("svg")
.last();
await checkSize(fileIcon);
await checkSize(directoryIcon);
await checkSize(find.getByRole("status", { name: "Loading", exact: true }));
for (const title of ["Stop", "Expand All", "Collapse All", "Close Tab"])
await checkSize(find.getByRole("button", { name: title, exact: true }).last().locator("svg"));
await page.evaluate(async () => {
const path = "/src/ui/iconAppearance.ts";
(await import(path)).setIconAppearance({ iconSize: 20, rowHeight: 28 });
});
await checkSize(fileIcon, 20);
await checkSize(directoryIcon, 20);
await checkSize(find.getByRole("status", { name: "Loading", exact: true }));
await find.getByRole("button", { name: "Stop", exact: true }).click();
await expect(find.getByRole("status", { name: "Loading", exact: true })).toHaveCount(0);
await checkSize(find.getByRole("button", { name: "Rerun", exact: true }).locator("svg"));
await find.getByRole("button", { name: "Rerun", exact: true }).click();
await expect(find.getByRole("status", { name: "Loading", exact: true })).toBeVisible();
await find.getByRole("button", { name: "Stop", exact: true }).click();
await page.evaluate(async () => {
const path = "/src/features/code-insight/usages.ts";
const { useUsagesPopup } = await import(path);
useUsagesPopup.setState({
open: true,
anchor: { x: 100, y: 150 },
symbol: "build",
loading: true,
groups: [
{
path: "/dev/acme-api/build.gradle.kts",
usages: [{ path: "/dev/acme-api/build.gradle.kts", line: 0, col: 0, endCol: 5, text: "build" }],
},
],
});
});
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
await checkSize(popup.getByRole("option").locator("svg"));
await checkSize(popup.getByRole("status", { name: "Loading", exact: true }));
const preview = popup.getByRole("button", { name: "Show Preview", exact: true });
await checkSize(preview.locator("svg"));
await preview.focus();
await page.keyboard.press("Enter");
await expect(popup.getByRole("region", { name: "Preview", exact: true })).toBeVisible();
await preview.click();
await expect(popup.getByRole("region", { name: "Preview", exact: true })).toHaveCount(0);
await popup.getByRole("button", { name: /Open in Find Window/ }).click();
const usages = page.getByRole("region", { name: "Find Usages", exact: true });
const usageTree = usages.getByRole("tree", { name: "Usages", exact: true });
await expect(usageTree.getByText("build.gradle.kts", { exact: true })).toBeVisible();
const usageIcon = usageTree
.getByRole("treeitem")
.filter({ has: page.getByText("build.gradle.kts", { exact: true }) })
.locator("svg")
.last();
await checkSize(usageIcon, 20);
await page.evaluate(async () => {
const path = "/src/features/code-insight/usages.ts";
const { useUsages } = await import(path);
useUsages.setState((s: { tabs: object[] }) => ({ tabs: s.tabs.map((t) => ({ ...t, loading: true })) }));
});
await checkSize(usages.getByRole("status", { name: "Loading", exact: true }));
await page.evaluate(async () => {
const path = "/src/ui/iconAppearance.ts";
(await import(path)).setIconAppearance(null);
});
await checkSize(usageIcon);
});
}
test(`Find in Files keeps its loading icon at native size in ${theme}`, async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(async (theme) => {
const path = "/src/workbench/theme.ts";
(await import(path)).previewTheme(theme);
window.__ipc.handlers.search_validate = () => null;
window.__ipc.handlers.search_start = () => null;
}, theme);
await page.keyboard.press("Meta+Shift+f");
const popup = page.getByRole("dialog", { name: "Find in Files", exact: true });
await popup.getByRole("textbox", { name: "Text to find" }).fill("build");
const spinner = popup.getByRole("status", { name: "Loading", exact: true });
await expect(spinner).toBeVisible();
await checkSize(spinner);
const center = await spinner.evaluate((node) => {
const icon = node.getBoundingClientRect();
const row = node.parentElement!.getBoundingClientRect();
return Math.abs(icon.y + icon.height / 2 - (row.y + row.height / 2));
});
expect(center).toBeLessThan(1);
await page.keyboard.press("Escape");
await expect(popup).toBeHidden();
});
}
+3 -3
View File
@@ -169,7 +169,7 @@ function UsagesPopupInner() {
)}
{loading && (
<span className={styles.searching} role="status" aria-label={tx("Searching for more usages")}>
<Spinner size={12} />
<Spinner size={16} variant="spokes" />
</span>
)}
{filter && (
@@ -178,7 +178,7 @@ function UsagesPopupInner() {
</span>
)}
<IconButton
icon="list"
icon="preview-details"
size="small"
title="Show Preview"
pressed={preview}
@@ -212,7 +212,7 @@ function UsagesPopupInner() {
}
renderItem={(u) => (
<div className={styles.row}>
<Icon name={fileIconName(basename(u.path), u.path)} size={14} className={styles.icon} />
<Icon name={fileIconName(basename(u.path), u.path)} size={16} className={styles.icon} />
<UsagePreview usage={u} />
<span className={styles.spacer} />
<span className={styles.where}>
+2 -2
View File
@@ -259,7 +259,7 @@ export function UsagesView() {
<div className={styles.view}>
<div className={styles.toolbar} role="toolbar" aria-orientation="vertical" aria-label={tx("Usages actions")}>
<IconButton
icon="rerun"
icon="refresh"
title={tx("Rerun Find Usages")}
size="small"
iconSize={16}
@@ -290,7 +290,7 @@ export function UsagesView() {
<div className={styles.summary} role="status" aria-live="polite">
{search.loading ? (
<>
<Spinner size={12} />{" "}
<Spinner size={16} variant="spokes" />{" "}
{search.symbol
? formatMessage(tx("Searching for usages of '{symbol}'"), { symbol: search.symbol })
: tx("Searching for usages")}
+3 -1
View File
@@ -621,7 +621,9 @@ function FindInFilesDialog() {
<header className={styles.header} data-dialog-drag="">
<span className={styles.title}>{s.replace ? tx("Replace in Files") : tx("Find in Files")}</span>
<span className={styles.status} aria-live="polite">
{stale || state.status === "searching" || state.status === "validating" ? <Spinner size={12} /> : null}
{stale || state.status === "searching" || state.status === "validating" ? (
<Spinner size={16} variant="spokes" />
) : null}
{summary}
</span>
<span className={styles.spacer} />
+3 -3
View File
@@ -370,7 +370,7 @@ function FindTabView({ tab }: { tab: FindTab }) {
return (
<div className={styles.body} onKeyDown={onKeyDown}>
<div className={styles.summary}>
{(st.status === "searching" || busy) && <Spinner size={12} />}
{(st.status === "searching" || busy) && <Spinner size={16} variant="spokes" />}
<span className={styles.title}>{tab.title}</span>
<span className={styles.count}>
{st.status === "invalid" || st.status === "error"
@@ -524,7 +524,7 @@ function FindNodeContent({ node, state, tab }: { node: Node; state: TreeRowState
case "dir":
return (
<span className={styles.node}>
<Icon name={state.expanded ? "folder-open" : "folder"} size={14} className={styles.icon} />
<Icon name={state.expanded ? "folder-open" : "folder"} size={16} className={styles.icon} />
<span className={styles.label}>{node.label}</span>
<span className={styles.meta}>
{node.count} {node.count === 1 ? "match" : "matches"}
@@ -534,7 +534,7 @@ function FindNodeContent({ node, state, tab }: { node: Node; state: TreeRowState
case "file":
return (
<span className={styles.node}>
<Icon name={fileIconName(node.name)} size={14} className={styles.icon} />
<Icon name={fileIconName(node.name)} size={16} className={styles.icon} />
<span className={styles.label}>{node.name}</span>
<span className={styles.meta}>{node.count}</span>
{!state.depth && node.dir && <span className={styles.meta}>{node.dir}</span>}
@@ -0,0 +1,6 @@
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.99994 3L11.9999 3C12.5522 3 12.9999 3.44772 12.9999 4L12.9999 6L2.99994 6L2.99994 4C2.99994 3.44772 3.44765 3 3.99994 3ZM1.99994 7L1.99994 12C1.99994 13.1046 2.89537 14 3.99994 14L11.9999 14C13.1045 14 13.9999 13.1046 13.9999 12L13.9999 4C13.9999 2.89543 13.1045 2 11.9999 2L3.99994 2C2.89537 2 1.99994 2.89543 1.99994 4L1.99994 6L1.99988 6L1.99988 7L1.99994 7ZM2.99994 7L12.9999 7L12.9999 12C12.9999 12.5523 12.5522 13 11.9999 13L3.99994 13C3.44765 13 2.99994 12.5523 2.99994 12L2.99994 7Z" fill="#6C707E"/>
<rect x="5" y="8.5" width="6" height="1" rx="0.5" fill="#6C707E"/>
<rect x="5" y="10.5" width="6" height="1" rx="0.5" fill="#6C707E"/>
</svg>

After

Width:  |  Height:  |  Size: 926 B

@@ -0,0 +1,6 @@
<!-- Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.99994 3L11.9999 3C12.5522 3 12.9999 3.44772 12.9999 4L12.9999 6L2.99994 6L2.99994 4C2.99994 3.44772 3.44765 3 3.99994 3ZM1.99994 7L1.99994 12C1.99994 13.1046 2.89537 14 3.99994 14L11.9999 14C13.1045 14 13.9999 13.1046 13.9999 12L13.9999 4C13.9999 2.89543 13.1045 2 11.9999 2L3.99994 2C2.89537 2 1.99994 2.89543 1.99994 4L1.99994 6L1.99988 6L1.99988 7L1.99994 7ZM2.99994 7L12.9999 7L12.9999 12C12.9999 12.5523 12.5522 13 11.9999 13L3.99994 13C3.44765 13 2.99994 12.5523 2.99994 12L2.99994 7Z" fill="#CED0D6"/>
<rect x="5" y="8.5" width="6" height="1" rx="0.5" fill="#CED0D6"/>
<rect x="5" y="10.5" width="6" height="1" rx="0.5" fill="#CED0D6"/>
</svg>

After

Width:  |  Height:  |  Size: 926 B

+1
View File
@@ -259,6 +259,7 @@ const ICONS = {
"split-horizontal": "general/splitHorizontally",
"editor-only": "general/editorOnly",
"editor-preview": "general/editorPreview",
"preview-details": "general/previewHorizontally",
"preview-only": "general/previewOnly",
maximize: "image/fitContent",
"zoom-in": "openidea/general/zoomIn",