git: fix blame decorations for third-party extension diff editors#287965
Open
AndyBodnar wants to merge 1 commit intomicrosoft:mainfrom
Open
git: fix blame decorations for third-party extension diff editors#287965AndyBodnar wants to merge 1 commit intomicrosoft:mainfrom
AndyBodnar wants to merge 1 commit intomicrosoft:mainfrom
Conversation
When diff editors are opened from third-party extensions like Git Graph or GitLens, the built-in git blame decorations were not displayed. This happened because getWorkingTreeDiffInformation() only recognizes VSCode's git URI scheme, returning undefined for other schemes used by extensions. This fix detects when there is valid diff information from third-party extensions (any diff with an original URI that is not stale) and treats the editor as viewing committed content. Since these extensions typically show committed file states rather than working tree modifications, we set workingTreeChanges to empty, allowing blame decorations to display correctly. Fixes microsoft#281045
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was using Git Graph to view commit diffs and noticed the blame decorations weren't showing up, even though they work fine when opening diffs from the Source Control view. Same thing happens with GitLens.
Dug into it and the issue is that
getWorkingTreeDiffInformation()only recognizes vscode's built-in git URI scheme, so it returns undefined for extensions that use their own schemes. The blame controller then bails out early thinking there's no valid diff info.The fix checks if there's any valid diff information available (regardless of scheme) and treats it as viewing committed content - which makes sense since these extensions are showing you historical states, not uncommitted changes. This lets the blame decorations display correctly.
I tested this with both Git Graph and GitLens - blame info now shows up properly in their diff views.
Fixes #281045