Skip to content

Commit

Permalink
feature: show shortest path in codepath UI
Browse files Browse the repository at this point in the history
  • Loading branch information
p- committed Jul 10, 2024
1 parent 7f6f9c9 commit 20617d2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions extensions/ql-vscode/src/view/common/CodePaths/CodePaths.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const ShowPathsLink = styled(VSCodeLink)`
cursor: pointer;
`;

const Label = styled.span`
color: var(--vscode-descriptionForeground);
margin-right: 10px;
margin-left: 10px;
`;

export type CodePathsProps = {
codeFlows: CodeFlow[];
ruleDescription: string;
Expand All @@ -37,9 +43,14 @@ export const CodePaths = ({
});
};

const allPathLengths = codeFlows
.map((codeFlow) => codeFlow.threadFlows.length)
.flat();
const shortestPath = Math.min(...allPathLengths);
return (
<>
<ShowPathsLink onClick={onShowPathsClick}>Show paths</ShowPathsLink>
<Label>(Shortest: {shortestPath})</Label>
</>
);
};

0 comments on commit 20617d2

Please sign in to comment.