дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
fix(search): keep file locations readable in Find in Files
Цей коміт міститься в:
1 джерело
0fc462350b
коміт
4fca7bf826
3 files changed
+49
-19
No files matched your search
@@ -5,6 +5,8 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const LONG_RESULT_PATH = "config/RegionalOrderReconciliationEndpointsForSandboxEnvironments.txt";
|
||||
|
||||
async function run(page: Page, id: string) {
|
||||
await page.evaluate(async (id) => {
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
@@ -15,15 +17,16 @@ async function run(page: Page, id: string) {
|
||||
|
||||
async function stubFindMatches(page: Page) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(() => {
|
||||
await page.evaluate((longPath) => {
|
||||
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 }];
|
||||
const relPath = i === 0 ? longPath : `config/endpoint-${i}.txt`;
|
||||
const lines = i === 0 ? [12344, 12345] : [0];
|
||||
const matches = lines.map((line) => ({ line, text, ranges: [[5, text.length]], textOffset: 0 }));
|
||||
send({
|
||||
type: "file",
|
||||
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
|
||||
@@ -31,12 +34,12 @@ async function stubFindMatches(page: Page) {
|
||||
}
|
||||
send({
|
||||
type: "done",
|
||||
summary: { files: 12, matches: 12, limitHit: false, cancelled: false, elapsedMs: 4 },
|
||||
summary: { files: 12, matches: 13, limitHit: false, cancelled: false, elapsedMs: 4 },
|
||||
});
|
||||
}, 20);
|
||||
return null;
|
||||
};
|
||||
});
|
||||
}, LONG_RESULT_PATH);
|
||||
}
|
||||
|
||||
async function expectControlsFit(page: Page) {
|
||||
@@ -74,7 +77,8 @@ test.describe("search popups at the minimum window width", () => {
|
||||
await expect(page.getByRole("dialog").locator("header [aria-live]")).toContainText(/match/);
|
||||
const dialog = page.getByRole("dialog");
|
||||
const title = dialog.getByText(id === "find.inPath" ? "Find in Files" : "Replace in Files", { exact: true });
|
||||
const count = dialog.getByText("12 matches in 12 files", { exact: true });
|
||||
const count = dialog.getByText("13 matches in 12 files", { exact: true });
|
||||
const line = dialog.getByText("12345", { exact: true });
|
||||
for (const [width, height] of [
|
||||
[400, 500],
|
||||
[600, 700],
|
||||
@@ -87,6 +91,14 @@ test.describe("search popups at the minimum window width", () => {
|
||||
expect(
|
||||
await text.evaluate((el) => el.getClientRects().length === 1 && el.scrollWidth <= el.clientWidth),
|
||||
).toBe(true);
|
||||
await expect(line).toBeVisible();
|
||||
expect(
|
||||
await line.evaluate(
|
||||
(el) => el.getBoundingClientRect().right <= el.parentElement!.getBoundingClientRect().right + 0.5,
|
||||
),
|
||||
"the line number fits even when the long filename is elided",
|
||||
).toBe(true);
|
||||
await expect(line.locator("..").getByTitle(LONG_RESULT_PATH)).toBeVisible();
|
||||
for (const name of ["Search Context", "Pin Window"])
|
||||
await dialog.getByRole("button", { name, exact: true }).click({ trial: true });
|
||||
}
|
||||
|
||||
@@ -162,8 +162,8 @@
|
||||
}
|
||||
.outdated .rowText,
|
||||
.outdated .rowText *,
|
||||
.outdated .rowFile,
|
||||
.outdated .rowFile * {
|
||||
.outdated .rowLocation,
|
||||
.outdated .rowLocation * {
|
||||
color: var(--fg-faint);
|
||||
}
|
||||
.rowText {
|
||||
@@ -174,18 +174,28 @@
|
||||
font-family: var(--font-mono);
|
||||
font-weight: var(--fw-code);
|
||||
}
|
||||
.rowFile {
|
||||
.rowLocation {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-1-5);
|
||||
max-width: 40%;
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.rowLocationActive {
|
||||
color: var(--fg-emphasis);
|
||||
}
|
||||
.rowFile {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.rowFileActive {
|
||||
.rowFileRepeated {
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.rowLine {
|
||||
color: var(--fg-faint);
|
||||
flex: none;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.previewHeader {
|
||||
|
||||
@@ -611,6 +611,7 @@ function FindInFilesDialog() {
|
||||
}
|
||||
renderItem={(r, st) => {
|
||||
const state = s.replace ? groupState(r, marks) : "pending";
|
||||
const repeatedFile = !st.active && rows[st.index - 1]?.path === r.path;
|
||||
return (
|
||||
<>
|
||||
<span
|
||||
@@ -626,13 +627,20 @@ function FindInFilesDialog() {
|
||||
source={{ path: r.path, line: r.line, col: r.textCol }}
|
||||
/>
|
||||
</span>
|
||||
<span className={clsx(styles.rowFile, st.active && styles.rowFileActive)}>
|
||||
{state === "done" && (
|
||||
<span className={styles.rowLine}>
|
||||
<T>replaced ·</T>{" "}
|
||||
</span>
|
||||
)}
|
||||
{workspace ? r.relPath : basename(r.relPath)} <span className={styles.rowLine}>{r.line + 1}</span>
|
||||
<span className={clsx(styles.rowLocation, st.active && styles.rowLocationActive)}>
|
||||
<span
|
||||
className={clsx(styles.rowFile, repeatedFile && styles.rowFileRepeated)}
|
||||
title={r.relPath}
|
||||
dir="auto"
|
||||
>
|
||||
{state === "done" && (
|
||||
<>
|
||||
<T>replaced ·</T>{" "}
|
||||
</>
|
||||
)}
|
||||
{workspace ? r.relPath : basename(r.relPath)}
|
||||
</span>{" "}
|
||||
<span className={styles.rowLine}>{r.line + 1}</span>
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in new issue
Заблокувати користувача