diff --git a/e2e/searchEverywhereLayout.spec.ts b/e2e/searchEverywhereLayout.spec.ts index abc760a18..f75ceb75c 100644 --- a/e2e/searchEverywhereLayout.spec.ts +++ b/e2e/searchEverywhereLayout.spec.ts @@ -1,4 +1,64 @@ import { doubleShift, expect, stubDesktop, test } from "./fixtures"; + +test("Search Everywhere keeps line numbers visible beside long Text result filenames", async ({ workbench: page }) => { + const relPath = "config/InternationalSettlementReconciliationEndpointsForStagingEnvironments.ts"; + const query = "settlementEndpoint"; + const text = `const ${query} = "/staging/settlement";`; + await stubDesktop(page); + await page.evaluate( + ({ relPath, text, query }) => { + window.__ipc.handlers.search_start = (args) => { + setTimeout(() => { + const matches = [12344, 12345].map((line) => ({ + line, + text, + ranges: [[6, 6 + query.length]], + textOffset: 0, + })); + window.__ipc.send(args.onEvent, { + type: "file", + file: { path: `/dev/acme-api/${relPath}`, relPath, matches }, + }); + window.__ipc.send(args.onEvent, { + type: "done", + summary: { files: 1, matches: 2, limitHit: false, cancelled: false, elapsedMs: 4 }, + }); + }, 20); + return null; + }; + }, + { relPath, text, query }, + ); + + await doubleShift(page); + const dialog = page.getByRole("dialog", { name: "Search Everywhere" }); + await dialog.getByRole("tab", { name: "Text", exact: true }).click(); + const search = dialog.getByRole("combobox", { name: "Search query" }); + await search.fill(query); + const rows = dialog.getByRole("option"); + await expect(rows).toHaveCount(2); + for (const width of [920, 440]) { + await page.setViewportSize({ width, height: 640 }); + for (const line of [12345, 12346]) { + const row = rows.filter({ hasText: String(line) }); + await expect(row.locator("mark")).toHaveText(query); + expect( + await row.evaluate((el) => { + const location = el.lastElementChild!; + const lineText = location.lastChild!; + const range = document.createRange(); + range.selectNodeContents(lineText); + const bounds = range.getBoundingClientRect(); + const clip = location.getBoundingClientRect(); + return bounds.width > 0 && bounds.left >= clip.left && bounds.right <= clip.right + 1; + }), + ).toBe(true); + await expect(row.getByText(relPath.split("/").at(-1)!, { exact: true })).toHaveAttribute("title", relPath); + } + } + await search.press("ArrowDown"); + await expect(rows.nth(1)).toHaveAttribute("aria-selected", "true"); +}); import type { Page } from "@playwright/test"; test("action names stay readable beside shortcuts and categories", async ({ workbench: page }) => { diff --git a/src/features/search/everywhere/SearchEverywhere.module.css b/src/features/search/everywhere/SearchEverywhere.module.css index ede8a364e..414e79d9c 100644 --- a/src/features/search/everywhere/SearchEverywhere.module.css +++ b/src/features/search/everywhere/SearchEverywhere.module.css @@ -248,6 +248,20 @@ .rightActive { color: var(--fg-muted); } +.textLocation { + display: inline-flex; + align-items: baseline; + gap: var(--space-1); +} +.textFile { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; +} +.textLine { + flex: none; + font-variant-numeric: tabular-nums; +} .actionRow { flex: 1; min-width: 0; diff --git a/src/features/search/everywhere/SearchEverywhere.tsx b/src/features/search/everywhere/SearchEverywhere.tsx index 64142066f..151084067 100644 --- a/src/features/search/everywhere/SearchEverywhere.tsx +++ b/src/features/search/everywhere/SearchEverywhere.tsx @@ -934,8 +934,11 @@ function ResultRow({ - - {basename(row.rel)} {row.line + 1} + + + {basename(row.rel)} + {" "} + {row.line + 1} );