From 6de1b2f0d55ddb8a92e1116826efeef79bb789c9 Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 14 Nov 2024 11:40:31 +0100 Subject: [PATCH] Also abbreviate RA names in predicate overview --- .../view/compare-performance/ComparePerformance.tsx | 8 +++++--- .../src/view/compare-performance/RAPrettyPrinter.tsx | 12 +++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx b/extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx index 4e759f888f2..74107a40374 100644 --- a/extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx +++ b/extensions/ql-vscode/src/view/compare-performance/ComparePerformance.tsx @@ -12,7 +12,7 @@ import type { import { formatDecimal } from "../../common/number"; import { styled } from "styled-components"; import { Codicon, ViewTitle, WarningBox } from "../common"; -import { abbreviateRASteps } from "./RAPrettyPrinter"; +import { abbreviateRANames, abbreviateRASteps } from "./RAPrettyPrinter"; const enum AbsentReason { NotSeen = "NotSeen", @@ -364,6 +364,8 @@ export function ComparePerformance(_: Record) { totalDiff += row.diff; } + const rowNames = abbreviateRANames(rows.map((row) => row.name)); + return ( <> Performance comparison @@ -406,7 +408,7 @@ export function ComparePerformance(_: Record) { - {rows.map((row) => ( + {rows.map((row, rowIndex) => ( ) { {renderAbsoluteValue(row.before)} {renderAbsoluteValue(row.after)} {renderDelta(row.diff)} - {row.name} + {rowNames[rowIndex]} {expandedPredicates.has(row.name) && ( <> diff --git a/extensions/ql-vscode/src/view/compare-performance/RAPrettyPrinter.tsx b/extensions/ql-vscode/src/view/compare-performance/RAPrettyPrinter.tsx index d02ef1e9c3a..39038a8e520 100644 --- a/extensions/ql-vscode/src/view/compare-performance/RAPrettyPrinter.tsx +++ b/extensions/ql-vscode/src/view/compare-performance/RAPrettyPrinter.tsx @@ -193,7 +193,12 @@ interface ExpandableNamePartProps { function ExpandableNamePart(props: ExpandableNamePartProps) { const [isExpanded, setExpanded] = useState(false); return ( - setExpanded(!isExpanded)}> + { + setExpanded(!isExpanded); + event.stopPropagation(); + }} + > {isExpanded ? props.children : "..."} ); @@ -269,3 +274,8 @@ export function abbreviateRASteps(steps: string[]): React.ReactNode[] { return {result}; }); } + +export function abbreviateRANames(names: string[]): React.ReactNode[] { + const nameSet = new NameSet(names); + return names.map((name) => nameSet.getAbbreviation(name)); +}