diff --git a/e2e/searchEverywhereLayout.spec.ts b/e2e/searchEverywhereLayout.spec.ts
index de1ed69e7..8917a90fa 100644
--- a/e2e/searchEverywhereLayout.spec.ts
+++ b/e2e/searchEverywhereLayout.spec.ts
@@ -190,3 +190,71 @@ test("mixed file and action rows align icons and names and keep shortcuts readab
expect(keys.x).toBeGreaterThanOrEqual(actionName.x + actionName.width);
expect(await shortcut.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
});
+
+test("file and class results keep distinguishing folders visible in a narrow popup", async ({ workbench: page }) => {
+ await page.setViewportSize({ width: 520, height: 608 });
+ await stubDesktop(page);
+ const prefix = "packages/commerce-platform/customer-account-management/src/main/typescript/customer";
+ const folders = ["renewal", "retention"];
+ await page.evaluate(
+ ({ prefix, folders }) => {
+ const files = folders.map((folder, index) => {
+ const relPath = `${prefix}/${folder}/OrderService.ts`;
+ return {
+ path: `/dev/acme-api/${relPath}`,
+ relPath,
+ score: 100 - index,
+ indices: Array.from("OrderService", (_, i) => i),
+ };
+ });
+ window.__ipc.handlers.find_files = () => files;
+ window.__ipc.handlers.find_symbols = () =>
+ files.map((file) => ({
+ ...file,
+ name: "OrderService",
+ kind: "class",
+ container: null,
+ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 12 } },
+ }));
+ },
+ { prefix, folders },
+ );
+
+ await doubleShift(page);
+ const dialog = page.getByRole("dialog", { name: "Search Everywhere" });
+ const query = dialog.getByRole("combobox", { name: "Search query" });
+ await query.fill("OrderService");
+ for (const tab of ["Files", "Classes"]) {
+ await dialog.getByRole("tab", { name: tab, exact: true }).click();
+ for (const folder of folders) {
+ const path = `${prefix}/${folder}`;
+ const result = dialog.getByRole("option", { name: new RegExp(folder) });
+ const label = result.getByText(path, { exact: true });
+ await expect(label).toBeVisible();
+ expect(
+ await label.evaluate((el, folder) => {
+ const text = el.lastChild?.nodeType === Node.TEXT_NODE ? el.lastChild : el.lastElementChild?.firstChild;
+ if (!text?.textContent?.endsWith(folder)) return false;
+ const range = document.createRange();
+ range.setStart(text, text.textContent.length - folder.length);
+ range.setEnd(text, text.textContent.length);
+ const label = el.getBoundingClientRect();
+ const clip = text.parentElement!.getBoundingClientRect();
+ const visible = range.getBoundingClientRect();
+ return visible.left >= Math.max(label.left, clip.left) && visible.right <= Math.min(label.right, clip.right);
+ }, folder),
+ ).toBe(true);
+ await expect(label).toHaveAttribute("title", path);
+ if (tab === "Files") {
+ const name = result.getByText("OrderService.ts", { exact: true });
+ expect(
+ await name.evaluate((el) => {
+ const range = document.createRange();
+ range.selectNodeContents(el);
+ return range.getBoundingClientRect().right <= el.getBoundingClientRect().right;
+ }),
+ ).toBe(true);
+ }
+ }
+ }
+});
diff --git a/src/features/search/everywhere/SearchEverywhere.module.css b/src/features/search/everywhere/SearchEverywhere.module.css
index fa00d0564..0a4880480 100644
--- a/src/features/search/everywhere/SearchEverywhere.module.css
+++ b/src/features/search/everywhere/SearchEverywhere.module.css
@@ -190,6 +190,10 @@
white-space: pre;
color: var(--fg-strong);
}
+.fileName {
+ flex-shrink: 0;
+ max-width: 100%;
+}
.code {
font-family: var(--font-ui);
color: var(--fg);
@@ -209,6 +213,20 @@
white-space: nowrap;
color: var(--fg-subtle);
}
+.path {
+ display: inline-flex;
+}
+.pathPart {
+ flex: none;
+ min-width: 0;
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+.pathPrefix {
+ flex-shrink: 1;
+}
.shortcut {
flex: none;
color: var(--fg-subtle);
diff --git a/src/features/search/everywhere/SearchEverywhere.tsx b/src/features/search/everywhere/SearchEverywhere.tsx
index 8c9c06f0b..6e8cb987e 100644
--- a/src/features/search/everywhere/SearchEverywhere.tsx
+++ b/src/features/search/everywhere/SearchEverywhere.tsx
@@ -858,9 +858,11 @@ function ResultRow({
{row.container && {row.container}}
-
- {row.section === "classes" ? relDir(row.rel) || basename(row.rel) : basename(row.rel)}
-
+ {row.section === "classes" ? (
+
+ ) : (
+ {basename(row.rel)}
+ )}
>
);
case "action": {
@@ -974,6 +976,16 @@ function CodeText({ path, text, indices }: { path: string; text: string; indices
);
}
+function ResultPath({ path, className }: { path: string; className?: string }) {
+ const separator = Math.max(0, path.lastIndexOf("/"));
+ return (
+
+ {separator > 0 && {path.slice(0, separator)}}
+ {path.slice(separator)}
+
+ );
+}
+
function FileRow({
path,
name,
@@ -995,11 +1007,11 @@ function FileRow({
<>
-
+
{line !== null && :{line + 1}}
- {dir && {dir}}
+ {dir && }
>
);