diff --git a/e2e/recentNavigationLayout.spec.ts b/e2e/recentNavigationLayout.spec.ts
new file mode 100644
index 000000000..ecc9ff931
--- /dev/null
+++ b/e2e/recentNavigationLayout.spec.ts
@@ -0,0 +1,94 @@
+import type { Page } from "@playwright/test";
+import { expect, stubDesktop, test } from "./fixtures";
+
+async function openRecent(page: Page, kind: "recentFiles" | "recentLocations") {
+ await page.evaluate(async (id) => {
+ const actions = "/src/platform/actions.ts";
+ void (await import(/* @vite-ignore */ actions)).executeAction(`navigate.${id}`);
+ }, kind);
+}
+
+test("Recent Files keeps directories beside names and leaves room for files in a narrow window", async ({
+ workbench: page,
+}) => {
+ await stubDesktop(page);
+ await page.evaluate(() => {
+ window.__ipc.handlers.recent_files = () => ["/dev/acme-api/src/orders/InvoiceService.ts"];
+ });
+ await openRecent(page, "recentFiles");
+ const dialog = page.getByRole("dialog", { name: "Recent Files", exact: true });
+ const files = dialog.getByRole("listbox", { name: "Recent files" });
+ const row = files.getByRole("option").first();
+ const name = row.getByText("InvoiceService.ts", { exact: true });
+ const directory = row.getByText("src/orders", { exact: true });
+ await expect(name).toBeVisible();
+ const nameRight = await name.evaluate((el) => el.getBoundingClientRect().right);
+ const dirLeft = (await directory.boundingBox())!.x;
+ expect(dirLeft - nameRight).toBeLessThanOrEqual(8);
+
+ await page.setViewportSize({ width: 400, height: 500 });
+ expect((await files.boundingBox())!.width).toBeGreaterThan(200);
+ expect((await dialog.getByRole("textbox", { name: "Filter recent files" }).boundingBox())!.width).toBeGreaterThan(
+ 200,
+ );
+ await expect.poll(() => directory.evaluate((el) => el.getBoundingClientRect().width)).toBeGreaterThan(20);
+ await expect(dialog.getByRole("button", { name: /Recent Locations/ })).toBeVisible();
+ const footer = dialog.locator("footer");
+ await expect(footer).toBeInViewport({ ratio: 1 });
+ expect(
+ await dialog.locator("[data-dialog-body]").evaluate((el) => el.scrollHeight - el.clientHeight),
+ ).toBeLessThanOrEqual(1);
+});
+
+test("Recent Locations keeps all snippet lines visible when the editor font grows", 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);
+ useTracking.setState({
+ locations: [
+ {
+ path: "/dev/acme-api/src/orders/CalculateOutstandingInvoicesForTheMonthlyReconciliation.ts",
+ line: 41,
+ col: 4,
+ changed: true,
+ time: Date.now(),
+ snippet: ["const invoices = await repository.openInvoices();", "return sum(invoices);", "}"],
+ snippetStart: 40,
+ },
+ ],
+ });
+ });
+ await openRecent(page, "recentLocations");
+ const dialog = page.getByRole("dialog", { name: "Recent Locations", exact: true });
+ const row = dialog.getByRole("option").first();
+ const code = row.locator("pre");
+ await expect(code).toContainText("return sum(invoices);");
+ await page.evaluate(async () => {
+ const project = "/src/platform/project.ts";
+ const { useProject } = await import(/* @vite-ignore */ project);
+ const { settings } = useProject.getState();
+ useProject.setState({
+ settings: {
+ ...settings,
+ editor: {
+ ...settings?.editor,
+ fontFamily: "Fira Code",
+ fallbackFont: "Maple Mono NF CN",
+ fontSize: 19,
+ lineHeight: 30,
+ },
+ },
+ });
+ });
+ await expect(code).toHaveCSS("font-size", "19px");
+ await expect(code).toHaveCSS("line-height", "30px");
+ await expect(code).toHaveCSS("font-family", /"Fira Code".*"Maple Mono NF CN"/);
+ expect((await code.boundingBox())!.height).toBe(90);
+
+ await page.setViewportSize({ width: 400, height: 500 });
+ const filter = dialog.getByRole("textbox", { name: "Filter recent locations" });
+ expect((await filter.boundingBox())!.width).toBeGreaterThan(200);
+ await expect(row.getByText("changed", { exact: true })).toBeInViewport({ ratio: 1 });
+ await expect(filter).toBeFocused();
+});
diff --git a/src/features/search/recent/RecentPopups.module.css b/src/features/search/recent/RecentPopups.module.css
index 917d0e581..c0b59fb9d 100644
--- a/src/features/search/recent/RecentPopups.module.css
+++ b/src/features/search/recent/RecentPopups.module.css
@@ -1,8 +1,14 @@
.dialog {
--rp-bg-chrome: var(--bg-frame, var(--bg-app));
+ container-type: inline-size;
max-height: 80vh;
background: var(--bg-popup, var(--bg-elev));
}
+.dialog > :global([data-dialog-body]) {
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+}
.header {
flex: none;
display: flex;
@@ -78,7 +84,7 @@
}
.tools {
flex: none;
- width: 230px;
+ width: clamp(140px, 32%, 230px);
display: flex;
flex-direction: column;
padding: 6px 0 4px;
@@ -132,9 +138,13 @@
.current {
font-style: italic;
}
+.fileName,
+.locationName {
+ flex: 0 1 auto;
+}
.dir {
- flex: none;
- max-width: 50%;
+ flex: 0 1000 auto;
+ min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
color: var(--fg-subtle);
@@ -162,23 +172,23 @@
}
.locationHeader {
display: flex;
+ flex: none;
align-items: center;
gap: var(--space-2);
height: 20px;
}
.locationName {
- flex: none;
+ font-weight: 600;
}
.changed {
+ flex: none;
margin-left: auto;
color: var(--vcs-modified);
font-size: var(--fs-small);
}
.snippet {
margin: 0;
- font-family: var(--font-mono);
- font-size: var(--fs-small);
- line-height: 16px;
+ font-size: var(--fs-code);
color: var(--fg-muted);
overflow: hidden;
}
@@ -233,3 +243,31 @@
overflow: hidden;
text-overflow: ellipsis;
}
+
+@container (max-width: 480px) {
+ .header {
+ height: auto;
+ flex-wrap: wrap;
+ gap: var(--space-2);
+ padding: var(--space-2) var(--space-3);
+ }
+ .speed {
+ order: 1;
+ flex-basis: 100%;
+ background: var(--bg-input);
+ box-shadow: inset 0 0 0 1px var(--border);
+ }
+ .speed .filterIcon {
+ visibility: visible;
+ }
+ .speed .filter {
+ caret-color: var(--fg-strong);
+ }
+ .hint,
+ .tools .shortcut {
+ display: none;
+ }
+ .locationsLink {
+ margin-inline: var(--space-1);
+ }
+}
diff --git a/src/features/search/recent/RecentPopups.tsx b/src/features/search/recent/RecentPopups.tsx
index e09e2c9d2..b4fbac567 100644
--- a/src/features/search/recent/RecentPopups.tsx
+++ b/src/features/search/recent/RecentPopups.tsx
@@ -1,9 +1,18 @@
import { useFilePresentation } from "@/ui/filePresentation";
-import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent as ReactMouseEvent } from "react";
+import {
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+ type CSSProperties,
+ type KeyboardEvent,
+ type MouseEvent as ReactMouseEvent,
+} from "react";
import { flushSync } from "react-dom";
import clsx from "clsx";
import { editorsFor, getNavigationHistory } from "@/editor/api";
import { call, commands, type OutlineItem } from "@/platform/ipc";
+import { monoFontFamily } from "@/platform/fonts";
import { shortcutLabel } from "@/platform/keymap";
import { useProject } from "@/platform/project";
import {
@@ -451,12 +460,12 @@ function RecentFileRow({ item, current }: { item: RecentFileItem; current: boole
<>
+
{segments.map((segs, i) => (
{first + i + 1}
@@ -581,6 +590,14 @@ function RecentLocationsDialog() {
const recorded = useTracking((s) => s.locations);
const dismissed = useTracking((s) => s.dismissed);
const root = useProject((s) => s.project?.root ?? null);
+ const editor = useProject((s) => s.settings?.editor);
+ const lineHeight = Math.max(editor?.fontSize ?? 13, editor?.lineHeight ?? 22);
+ const rowHeight = 30 + 3 * lineHeight;
+ const snippetStyle: CSSProperties = {
+ fontFamily: monoFontFamily(editor?.fontFamily ?? undefined, editor?.fallbackFont, "var(--font-mono)"),
+ fontSize: editor?.fontSize ?? undefined,
+ lineHeight: `${lineHeight}px`,
+ };
const [query, setQuery] = useState("");
const [index, setIndex] = useState(0);
const inputRef = useRef(null);
@@ -659,6 +676,7 @@ function RecentLocationsDialog() {
`${l.path}:${l.line}:${l.time}`}
activeIndex={active}
@@ -669,7 +687,7 @@ function RecentLocationsDialog() {
open(l, e.shiftKey);
}}
focusable={false}
- rowHeight={LOCATION_ROW}
+ rowHeight={rowHeight}
aria-label="Recent locations"
empty={{changedOnly ? tx("No changed locations") : tx("No recent locations")}}
renderItem={(l) => (
@@ -677,7 +695,7 @@ function RecentLocationsDialog() {
{locationTime(l.time, now)}
-
+
)}
/>