diff --git a/e2e/problems-layout.spec.ts b/e2e/problems-layout.spec.ts new file mode 100644 index 0000000000..e8b14b4ba0 --- /dev/null +++ b/e2e/problems-layout.spec.ts @@ -0,0 +1,34 @@ +import { expect, test } from "./fixtures"; + +test("keeps diagnostic text and file counts visible in a narrow Problems pane", async ({ workbench: page }) => { + await page.setViewportSize({ width: 720, height: 760 }); + await page.evaluate(async () => { + const projectModule = "/src/platform/project.ts"; + const problemsModule = "/src/features/code-insight/problemsStore.ts"; + const { useProject } = await import(/* @vite-ignore */ projectModule); + const { applyDiagnosticsEvent } = await import(/* @vite-ignore */ problemsModule); + const root = useProject.getState().project.root; + const path = `${root}/src/features/checkout/shared/services/with-a-long-directory-name/for-order-processing/orders.ts`; + const source = "typescript-eslint-application-rules-with-a-very-long-source-label"; + applyDiagnosticsEvent(path, source, [ + { + range: { start: { line: 2, col: 2 }, end: { line: 2, col: 9 } }, + severity: "error", + source, + message: "Invalid order total", + }, + ]); + }); + + await page.getByRole("button", { name: "Problems", exact: true }).click(); + const pane = page.locator('[data-toolwindow="problems"]'); + await pane.getByRole("tab", { name: /Project Errors/ }).click(); + await expect(pane.getByRole("toolbar", { name: "Problems actions" })).toHaveAttribute("aria-orientation", "vertical"); + const tree = pane.getByRole("tree", { name: "Problems" }); + const count = tree.getByText("1 error", { exact: true }); + const message = tree.getByText("Invalid order total", { exact: true }); + await expect(count).toBeVisible(); + await expect(message).toBeVisible(); + await expect.poll(() => message.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true); + await expect.poll(() => tree.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true); +}); diff --git a/src/features/code-insight/ProblemsView.module.css b/src/features/code-insight/ProblemsView.module.css index 1eaa34972c..4cd7316a9d 100644 --- a/src/features/code-insight/ProblemsView.module.css +++ b/src/features/code-insight/ProblemsView.module.css @@ -14,6 +14,24 @@ flex: 1; min-height: 0; } +.results { + display: flex; + min-height: 0; + height: 100%; +} +.toolbar { + flex: none; + display: flex; + flex-direction: column; + gap: var(--space-1); + padding: var(--space-1); + border-inline-end: 1px solid var(--border); + overflow-y: auto; +} +.tree { + flex: 1; + min-width: 0; +} .tabs { min-width: 0; border: 0; @@ -38,10 +56,21 @@ flex: none; color: var(--fg-muted); } +.fileLocation { + display: flex; + gap: var(--space-1-5); + min-width: 0; + overflow: hidden; +} .fileName { + flex: none; + max-inline-size: 100%; + overflow: hidden; + text-overflow: ellipsis; color: var(--fg-strong); } .fileError { + padding-block: var(--space-0-5); text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: var(--danger); @@ -51,18 +80,25 @@ .selectedText { color: var(--fg-strong); } -.muted { - flex: none; +.directory { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; color: var(--fg-subtle); } .count { + flex: none; + max-inline-size: 50%; + overflow: hidden; + text-overflow: ellipsis; color: var(--fg-subtle); - margin-left: 4px; } .source { - flex: none; - margin-left: auto; - padding-right: 8px; + min-width: 0; + max-inline-size: 25%; + margin-inline-start: auto; + overflow: hidden; + text-overflow: ellipsis; color: var(--fg-faint); } .message { @@ -77,6 +113,7 @@ .position { flex: none; color: var(--fg-subtle); + font-variant-numeric: tabular-nums; } .sev-error { flex: none; diff --git a/src/features/code-insight/ProblemsView.tsx b/src/features/code-insight/ProblemsView.tsx index ec82770e57..054daf2326 100644 --- a/src/features/code-insight/ProblemsView.tsx +++ b/src/features/code-insight/ProblemsView.tsx @@ -22,6 +22,7 @@ import { SplitHandle, SplitPanel, Tabs, + Toolbar, Tree, fileIconName, showContextMenu, @@ -213,11 +214,11 @@ function useCurrentPath(): string | null { return currentProblemsPath(text, useSyncExternalStore(subscribeActiveInput, activeInput)); } -export function ProblemsHeaderActions() { +function ProblemsToolbar() { const show = useProblemsView((s) => s.show); const toggle = useProblemsView((s) => s.toggle); return ( - <> + toggle("error")} /> @@ -235,7 +236,7 @@ export function ProblemsHeaderActions() { pressed={show.info} onClick={() => toggle("info")} /> - + ); } @@ -337,33 +338,44 @@ export function ProblemsView() { const renderNode = (n: Node, state: TreeRowState) => { if (n.kind === "file") { + const name = basename(n.path); + const directory = relativeDir(root, n.path); const c = countSeverities(n.items); - const parts = [plural(c.error, "error"), plural(c.warning, "warning"), plural(c.info + c.hint, "info")].filter( - Boolean, - ); + const counts = [plural(c.error, "error"), plural(c.warning, "warning"), plural(c.info + c.hint, "info")] + .filter(Boolean) + .join(", "); return ( - - 0 && styles.fileError, state.selected && styles.selectedText)} - > - {basename(n.path)} + + + 0 && styles.fileError, state.selected && styles.selectedText)} + title={name} + > + {name} + + {directory && ( + + {directory} + + )} + + + {counts} - {relativeDir(root, n.path)} - {parts.join(", ")} ); } const d = n.d; + const source = d.source && (d.code ? `${d.source}(${d.code})` : d.source); return ( {d.message.split("\n")[0]} :{d.range.start.line + 1} - {d.source && ( - - {d.source} - {d.code ? `(${d.code})` : ""} + {source && ( + + {source} )} @@ -378,9 +390,10 @@ export function ProblemsView() { ); const selected = target(lead); - const list = ( + const treeView = ( aria-label="Problems" + className={styles.tree} handleRef={tree} roots={roots} getKey={(n) => n.key} @@ -428,7 +441,11 @@ export function ProblemsView() { run: () => copy(n), }, ...inspectionMenu(n.kind === "diag" ? diagInspection(map, n.path, n.d) : null), - ...menuGroupItems("problems", { paths: [t.path], line: t.d.range.start.line, column: t.d.range.start.col }), + ...menuGroupItems("problems", { + paths: [t.path], + line: t.d.range.start.line, + column: t.d.range.start.col, + }), ]); }} activateExpandable={false} @@ -436,6 +453,12 @@ export function ProblemsView() { empty={empty} /> ); + const list = ( +
+ + {treeView} +
+ ); return (
diff --git a/src/features/code-insight/index.ts b/src/features/code-insight/index.ts index a7a4062d08..085f17e3c8 100644 --- a/src/features/code-insight/index.ts +++ b/src/features/code-insight/index.ts @@ -15,7 +15,7 @@ import { import { getContext } from "@/platform/context"; import { clearProblems, installProblemsEvents, problemsReport, useProblems } from "./problemsStore"; import { installProblemDecorations } from "./decorations"; -import { ProblemsHeaderActions, ProblemsTabs, ProblemsView, useProblemsHeaderMenu } from "./ProblemsView"; +import { ProblemsTabs, ProblemsView, useProblemsHeaderMenu } from "./ProblemsView"; import { UsagesTabs, UsagesView, useUsagesHeaderMenu } from "./UsagesView"; import { UsagesPopup } from "./UsagesPopup"; import { findUsages, rerunActiveUsages, resetUsages, showUsageResults, showUsagesPopup } from "./usages"; @@ -79,7 +79,6 @@ export function activate(): () => void { order: 30, component: ProblemsView, headerContent: ProblemsTabs, - headerActions: ProblemsHeaderActions, headerMenu: useProblemsHeaderMenu, useBadge: useErrorBadge, }), diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index 7f94d295b6..5ad5f8f505 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -1,4 +1,5 @@ { + "Problems actions": "Problems actions", "Same as the existing configuration '{existing}'": "Same as the existing configuration '{existing}'", "Windows file and folder names cannot end with a period or space": "Windows file and folder names cannot end with a period or space", "Use URL template": "Use URL template", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index 68fa7c3357..cae3011df9 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -1,4 +1,5 @@ { + "Problems actions": "问题操作", "Windows file and folder names cannot end with a period or space": "Windows 文件和文件夹名称不能以句点或空格结尾", "Use URL template": "使用 URL 模板", "Use Driver": "使用驱动程序",