diff --git a/e2e/recentNavigationLayout.spec.ts b/e2e/recentNavigationLayout.spec.ts index 57889c4d2..428c2be6f 100644 --- a/e2e/recentNavigationLayout.spec.ts +++ b/e2e/recentNavigationLayout.spec.ts @@ -93,3 +93,42 @@ test("Recent Locations keeps all snippet lines visible when the editor font grow await expect(row.getByText("changed", { exact: true })).toBeInViewport({ ratio: 1 }); await expect(filter).toBeFocused(); }); + +test("Recent Locations shows each file name once with its parent directory", async ({ workbench: page }) => { + await stubDesktop(page); + await page.evaluate(async () => { + const tracking = "/src/features/search/common/tracking.ts"; + const { useTracking } = await import(/* @vite-ignore */ tracking); + const now = Date.now(); + useTracking.setState({ + locations: [ + ["README.md", "# Shop API"], + ["packages/billing/Routes.ts", "registerBillingRoutes();"], + ["packages/checkout/Routes.ts", "registerCheckoutRoutes();"], + ].map(([path, snippet], index) => ({ + path: `/dev/acme-api/${path}`, + line: 0, + col: 0, + changed: false, + time: now - index * 60000, + snippet: [snippet], + snippetStart: 0, + })), + }); + }); + await openRecent(page, "recentLocations"); + const dialog = page.getByRole("dialog", { name: "Recent Locations", exact: true }); + const rows = dialog.getByRole("option"); + await expect(rows).toHaveCount(3); + await expect(rows.filter({ hasText: "# Shop API" }).getByText("README.md", { exact: true })).toHaveCount(1); + + const billing = rows.filter({ hasText: "registerBillingRoutes();" }); + const checkout = rows.filter({ hasText: "registerCheckoutRoutes();" }); + await expect(billing.getByText("packages/billing", { exact: true })).toBeVisible(); + await expect(checkout.getByText("packages/checkout", { exact: true })).toBeVisible(); + await expect(checkout.getByTitle("packages/checkout/Routes.ts", { exact: true })).toBeVisible(); + + await dialog.getByRole("textbox", { name: "Filter recent locations" }).fill("packages/checkout"); + await expect(rows).toHaveCount(1); + await expect(rows.first()).toContainText("registerCheckoutRoutes();"); +}); diff --git a/src/features/search/recent/RecentPopups.tsx b/src/features/search/recent/RecentPopups.tsx index 21ba6f13b..9afa131fc 100644 --- a/src/features/search/recent/RecentPopups.tsx +++ b/src/features/search/recent/RecentPopups.tsx @@ -15,6 +15,7 @@ import { call, commands, type OutlineItem } from "@/platform/ipc"; import { monoFontFamily } from "@/platform/fonts"; import { shortcutLabel } from "@/platform/keymap"; import { useProject } from "@/platform/project"; +import { isVirtualUri, virtualContainer } from "@/platform/virtualDocs"; import { Checkbox, Dialog, @@ -40,7 +41,7 @@ import { type ToolWindowContribution, } from "@/workbench/contributions"; import { highlightTokens, languageForPath, type CodeToken } from "@/editor/lsp/markdown"; -import { basename, openInListOrder, openLocation } from "../common/open"; +import { basename, openInListOrder, openLocation, relDir } from "../common/open"; import { outlinePathAt } from "../structure/outline"; import { fromNavigationHistory, isDismissed, mergeLocations, type RecentLocation } from "../common/locations"; import { dismissLocation, useTracking } from "../common/tracking"; @@ -688,33 +689,39 @@ function RecentLocationsDialog() { rowHeight={rowHeight} aria-label="Recent locations" empty={{changedOnly ? tx("No changed locations") : tx("No recent locations")}} - renderItem={(l) => ( -