SCM - refactor history item hover for the graph #278778
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the SCM history item hover rendering to support arrays of MarkdownString objects for the graph view. The main changes enable VS Code to inject reference badges with appropriate colors into history item hovers, since extensions don't have access to the graph coloring information.
- Extends the tooltip API to support arrays of MarkdownString objects instead of just strings or single MarkdownStrings
- Moves hover rendering logic from the git extension to VS Code's SCM view layer
- Creates a new shared
hover.tsmodule in the git extension for reusable hover generation functions - Updates CSS selectors to support the new multi-markdown structure
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.scmHistoryProvider.d.ts | Updates tooltip API to support MarkdownString | Array<MarkdownString> instead of string | MarkdownString |
| src/vs/workbench/contrib/scm/common/history.ts | Updates internal tooltip type to match the new API definition |
| src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts | Adds _renderHoverContent method to handle tooltip arrays and inject reference badges with colors |
| src/vs/workbench/contrib/scm/browser/media/scm.css | Updates CSS selectors to target the new .history-item-hover-container and .rendered-markdown structure |
| src/vs/workbench/api/common/extHostSCM.ts | Converts extension tooltip data using MarkdownString.fromMany for arrays |
| src/vs/workbench/api/common/extHost.protocol.ts | Updates the DTO type definition to match the new API |
| extensions/git/src/hover.ts | New file containing shared hover generation functions extracted from historyProvider.ts |
| extensions/git/src/historyProvider.ts | Removes hover rendering logic and references/backgroundColor properties from history item refs |
| extensions/git/src/timelineProvider.ts | Updates to use the new hover functions from hover.ts |
| extensions/git/src/blame.ts | Updates to use the new hover functions from hover.ts |
| } | ||
|
|
||
| markdownString.appendMarkdown(`\n\n---\n\n`); | ||
| historyItem.tooltip.splice(historyItem.tooltip.length - 1, 0, markdownString); |
There was a problem hiding this comment.
Direct mutation of the tooltip array should be avoided as it modifies the original data structure from the extension. This can lead to unexpected behavior if the tooltip is rendered multiple times or cached by the extension. Consider creating a new array instead:
const tooltipWithReferences = [...historyItem.tooltip];
tooltipWithReferences.splice(tooltipWithReferences.length - 1, 0, markdownString);Then iterate over tooltipWithReferences in the loop below instead of historyItem.tooltip.
No description provided.