Compare commits

...
Author SHA1 Message Date
l0ng-ai 56a133e61d fix(search): keep multiline file search fields compact 2026-11-23 12:38:22 +08:00
4 changed files with 38 additions and 8 deletions

No files matched your search

+30 -1
View File
@@ -3,7 +3,7 @@
* header on screen: titles stay on one line and every header control lies inside the popup.
*/
import type { Page } from "@playwright/test";
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
const LONG_RESULT_PATH = "config/RegionalOrderReconciliationEndpointsForSandboxEnvironments.txt";
@@ -118,6 +118,35 @@ test.describe("search popups at the minimum window width", () => {
await dialog.getByRole("button", { name: /Browse/ }).click({ trial: true });
});
test("multi-line search and replacement leave room for matches and scroll inside their fields", async ({
workbench: page,
}) => {
await stubFindMatches(page);
await run(page, "find.replaceInPath");
const dialog = page.getByRole("dialog", { name: "Replace in Files" });
const search = dialog.getByRole("textbox", { name: "Text to find" });
const replacement = dialog.getByRole("textbox", { name: "Replace with" });
const query = "base=http://localhost:8080\nregion=eu-west\nmode=batch\nverify=true\nretry=2\ntimeout=30";
const changed = query.replace("localhost:8080", "localhost:9443").replace("retry=2", "retry=4");
await search.fill(query);
await replacement.fill(changed);
for (const field of [search, replacement]) {
const visibleLines = await field.evaluate((el) => el.clientHeight / parseFloat(getComputedStyle(el).lineHeight));
expect(visibleLines).toBeCloseTo(3);
await field.press("Control+End");
await expect.poll(() => field.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
}
await expect(search).toHaveValue(query);
await expect(replacement).toHaveValue(changed);
await expect(dialog.getByRole("listbox", { name: "Matches" }).getByRole("option").first()).toBeInViewport();
const calls = await ipcCalls(page, "search_start");
expect(calls.some(({ query: sent }) => (sent as { pattern: string }).pattern === query)).toBe(true);
await expect(dialog.getByRole("button", { name: "Replace All", exact: true })).toBeInViewport({ ratio: 1 });
await replacement.fill("updated");
await expect(replacement).toHaveAttribute("rows", "1");
});
test("Replace in Files keeps its footer actions together as the window narrows", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1120, height: 750 });
await openFromTree(page, "settings.gradle.kts");
@@ -83,18 +83,14 @@
flex: none;
display: flex;
flex-direction: column;
gap: var(--space-2);
padding: 8px 8px 0;
gap: var(--space-1);
padding: var(--space-2) var(--space-2) 0;
}
/* The query fields sit on the popup surface, framed only by their border. */
.fields .field {
width: 100%;
background: transparent;
}
.field input {
font-family: var(--font-mono);
font-size: var(--fs-code);
}
.error {
color: var(--danger);
font-size: var(--fs-small);
+2
View File
@@ -717,6 +717,7 @@ function FindInFilesDialog() {
invalid={state.status === "invalid"}
className={styles.field}
multiline
maxRows={3}
onHistory={() => setHistoryMenu("find")}
toggles={[
{
@@ -757,6 +758,7 @@ function FindInFilesDialog() {
aria-label="Replace with"
className={styles.field}
multiline
maxRows={3}
onHistory={() => setHistoryMenu("replace")}
toggles={[
{
+4 -1
View File
@@ -95,6 +95,8 @@ export interface SearchFieldProps extends Omit<InputHTMLAttributes<HTMLInputElem
* text, plus a New Line button (⇧⌘↵ / ⇧Ctrl↵ inserts one too).
*/
multiline?: boolean;
/** How many lines of a search query stay visible before the field scrolls. */
maxRows?: number;
/** Turns the leading magnifier into IDEA's search-history button (magnifier ▾). */
onHistory?: () => void;
}
@@ -132,6 +134,7 @@ export const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(functi
className,
placeholder,
multiline,
maxRows = 5,
onHistory,
"aria-label": ariaLabel,
...rest
@@ -227,7 +230,7 @@ export const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(functi
<textarea
ref={setRef as Ref<HTMLTextAreaElement>}
className={clsx(styles.searchInput, styles.searchArea, lines === 1 && styles.searchAreaSingle)}
rows={Math.min(lines, 5)}
rows={Math.min(lines, maxRows)}
wrap="off"
value={value}
spellCheck={false}