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

...
4 змінених файлів з 78 додано та 53 видалено

No files matched your search

+68 -29
Переглянути файл
@@ -13,6 +13,32 @@ async function run(page: Page, id: string) {
}, id);
}
async function stubFindMatches(page: Page) {
await stubDesktop(page);
await page.evaluate(() => {
window.__ipc.handlers.search_validate = () => null;
window.__ipc.handlers.search_start = (args) => {
const send = (event: unknown) => window.__ipc.send(args.onEvent, event);
const text = "base=http://localhost:8080";
setTimeout(() => {
for (let i = 0; i < 12; i++) {
const relPath = `config/endpoint-${i}.txt`;
const matches = [{ line: 0, text, ranges: [[5, text.length]], textOffset: 0 }];
send({
type: "file",
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
});
}
send({
type: "done",
summary: { files: 12, matches: 12, limitHit: false, cancelled: false, elapsedMs: 4 },
});
}, 20);
return null;
};
});
}
async function expectControlsFit(page: Page) {
const dialog = page.getByRole("dialog");
await expect(dialog).toBeVisible();
@@ -42,35 +68,7 @@ test.describe("search popups at the minimum window width", () => {
for (const id of ["find.inPath", "find.replaceInPath"]) {
test(`${id} keeps its title, count and buttons visible`, async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(() => {
window.__ipc.handlers.search_validate = () => null;
window.__ipc.handlers.search_start = (args) => {
const send = (event: unknown) => window.__ipc.send(args.onEvent, event);
const text = "base=http://localhost:8080";
setTimeout(() => {
for (let i = 0; i < 12; i++) {
const relPath = `config/endpoint-${i}.txt`;
const matches = [{ line: 0, text, ranges: [[5, text.length]], textOffset: 0 }];
send({
type: "file",
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
});
}
send({
type: "done",
summary: {
files: 12,
matches: 12,
limitHit: false,
cancelled: false,
elapsedMs: 4,
},
});
}, 20);
return null;
};
});
await stubFindMatches(page);
await run(page, id);
await page.getByRole("dialog").getByPlaceholder("Search").fill("http://localhost:8080");
await expect(page.getByRole("dialog").locator("header [aria-live]")).toContainText(/match/);
@@ -95,6 +93,19 @@ test.describe("search popups at the minimum window width", () => {
});
}
test("directory scope gives the path field room at the minimum width", async ({ workbench: page }) => {
await stubDesktop(page);
await run(page, "find.inPath");
const dialog = page.getByRole("dialog", { name: "Find in Files" });
await dialog.getByRole("tab", { name: "Directory", exact: true }).click();
const input = dialog.getByRole("textbox", { name: "Directory", exact: true });
await expect(input).toBeVisible();
const { width } = (await input.boundingBox())!;
expect(width).toBeGreaterThan(200);
await expectControlsFit(page);
await dialog.getByRole("button", { name: /Browse/ }).click({ trial: true });
});
for (const id of [
"navigate.searchEverywhere",
"navigate.searchText",
@@ -111,3 +122,31 @@ test.describe("search popups at the minimum window width", () => {
});
}
});
test("Find in Files prioritizes the preview and remembers an adjusted split", async ({ workbench: page }) => {
await stubFindMatches(page);
await run(page, "find.inPath");
const dialog = page.getByRole("dialog", { name: "Find in Files" });
await dialog.getByPlaceholder("Search").fill("http://localhost:8080");
const results = dialog.locator("[data-panel][id=results]");
const preview = dialog.locator("[data-panel][id=preview]");
const handle = dialog.getByTestId("find-popup-split").getByRole("separator");
const resultsShare = async () => {
const resultHeight = (await results.boundingBox())!.height;
const previewHeight = (await preview.boundingBox())!.height;
return resultHeight / (resultHeight + previewHeight);
};
await expect(handle).toBeAttached();
await expect.poll(resultsShare).toBeCloseTo(0.33, 2);
await handle.press("ArrowUp");
await expect.poll(resultsShare).toBeLessThan(0.31);
const adjusted = await resultsShare();
await page.setViewportSize({ width: 400, height: 500 });
await expect.poll(resultsShare).toBeGreaterThan(adjusted + 0.02);
await dialog.getByPlaceholder("Search").press("Escape");
await expect(dialog).toBeHidden();
await page.setViewportSize({ width: 1400, height: 900 });
await run(page, "find.inPath");
await expect(handle).toBeAttached();
await expect.poll(resultsShare).toBeCloseTo(adjusted, 2);
});
+6 -2
Переглянути файл
@@ -106,18 +106,22 @@
--border-tab-selected: transparent;
flex: none;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-3);
gap: var(--space-1) var(--space-3);
padding: 8px 14px 4px 20px;
}
.scopeDetail {
flex: 1;
flex: 1 1 200px;
min-width: 0;
display: flex;
align-items: center;
justify-content: flex-end;
gap: var(--space-1);
}
.scopeDetail:empty {
display: none;
}
.dirInput {
width: 100%;
max-width: 420px;
+3 -9
Переглянути файл
@@ -67,6 +67,7 @@ import {
import { SINGLE_FIRST, isRowSelected, selectRow, selectedRows, type RowSelection } from "./rowSelection";
import { FindSession, IDLE, matchRows, type FindState, type MatchRow } from "./session";
import {
FIND_POPUP_SPLIT_KEY,
SEARCH_CONTEXTS,
buildQuery,
customScopeName,
@@ -82,9 +83,7 @@ import {
resolveFindScope,
setFindPopupCommandHandler,
loadFindPopupSize,
loadFindPopupSplit,
saveFindPopupSize,
saveFindPopupSplit,
setFindPopupNewTab,
setFindPopupPinned,
useFindPopup,
@@ -165,11 +164,6 @@ function FindInFilesDialog() {
const [previewMode, setPreviewMode] = useState(false);
const [diffPreview, setDiffPreview] = useState<{ key: string; lines: PreviewLine[] } | null>(null);
const [initialSize] = useState(loadFindPopupSize);
const [split, setSplit] = useState(loadFindPopupSplit);
const keepSplit = (layout: Record<string, number>) => {
setSplit(layout);
saveFindPopupSplit(layout);
};
const [marks, setMarks] = useState<ReplaceMarks>(NO_MARKS);
const [running, setRunning] = useState<ReplaceRun | null>(null);
const [progress, setProgress] = useState<ReplaceProgress | null>(null);
@@ -869,8 +863,8 @@ function FindInFilesDialog() {
</div>
<div className={styles.split}>
{rows.length ? (
<SplitGroup orientation="vertical" id="find-popup-split" defaultLayout={split} onLayoutChanged={keepSplit}>
<SplitPanel id="results" minSize={ROW * 3} defaultSize="48%">
<SplitGroup orientation="vertical" id="find-popup-split" storageKey={FIND_POPUP_SPLIT_KEY}>
<SplitPanel id="results" minSize={ROW * 3} defaultSize="33%">
{resultsBox}
</SplitPanel>
<SplitHandle hairline={false} />
+1 -13
Переглянути файл
@@ -98,9 +98,8 @@ export function setFindPopupNewTab(newTab: boolean) {
}
const SIZE_KEY = "openidea.search.findPopupSize.v1";
const SPLIT_KEY = "openidea.search.findPopupSplit.v1";
export const FIND_POPUP_SPLIT_KEY = "openidea.search.findPopupSplit.v1";
/** The popup's size and its results / preview split, remembered like IDEA's. */
export function loadFindPopupSize(): { w: number; h: number } | null {
const v = loadJson<{ w?: unknown; h?: unknown } | null>(SIZE_KEY, null);
return typeof v?.w === "number" && typeof v.h === "number" ? { w: v.w, h: v.h } : null;
@@ -110,17 +109,6 @@ export function saveFindPopupSize(size: { w: number; h: number }) {
saveJson(SIZE_KEY, size);
}
export function loadFindPopupSplit(): Record<string, number> | undefined {
const v = loadJson<unknown>(SPLIT_KEY, null);
return v && typeof v === "object" && Object.values(v).every((n) => typeof n === "number")
? (v as Record<string, number>)
: undefined;
}
export function saveFindPopupSplit(layout: Record<string, number>) {
saveJson(SPLIT_KEY, layout);
}
/**
* Keys the popup handles that are also global shortcuts (⌘G / ⇧⌘G, F4 / ⌘↓, ⌥↓):
* hidden actions bound later in the keymap win while the popup is open and