Repository navigation
Fix commenting on added files in the Commits tree - #8866
Closed
Artur Czuba (artur-czuba-iyuno) wants to merge 1 commit into
Closed
Artur Czuba (artur-czuba-iyuno) wants to merge 1 commit into
Artur Czuba (artur-czuba-iyuno) wants to merge 1 commit into
Conversation
When a file added by a commit is opened from the Commits node, the right-hand side of the diff is given `parentFilePath`, which is a `review` uri with `base: true`. `ReviewCommentController.provideCommentingRanges` then calls `getCommentingRanges(hunks, isBase: true)`, which builds ranges only from `Delete` diff lines. An added file has none, so no commenting ranges are produced and the `+` never appears in the gutter. Use `filePath` for the head side instead. The `DELETE` case is left as it is: the content of a deleted file lives on the base side, and so does the comment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot started reviewing on behalf of
Artur Czuba (artur-czuba-iyuno)
July 30, 2026 10:11
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes commenting support when opening diffs for added files from the Commits tree by ensuring the head-side document URI is used, allowing ReviewCommentController.provideCommentingRanges to generate valid commenting ranges.
Changes:
- Use
changeModel.filePath(head side) instead ofchangeModel.parentFilePath(base side) when diffing added files from the Commits tree. - Add unit tests to verify added files use the head-side URI and deleted files continue to use the base-side URI.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/view/treeNodes/fileChangeNode.ts |
Adjusts the vscode.diff arguments for added files so commenting ranges are computed on the correct (head) side. |
src/test/view/treeNodes/gitFileChangeNode.test.ts |
Adds coverage for the added vs deleted file diff-URI behavior in the Commits tree. |
Comments suppressed due to low confidence (1)
src/test/view/treeNodes/gitFileChangeNode.test.ts:88
- Same as above:
vscode.diffcommand arguments include non-URI values after the first two entries, soas vscode.Uri[]is misleading. Use a tuple type to capture the expected shape.
const [left, right] = node.command.arguments as vscode.Uri[];
| await node.resolve(); | ||
|
|
||
| assert.strictEqual(node.command.command, 'vscode.diff'); | ||
| const [left, right] = node.command.arguments as vscode.Uri[]; |
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.
When a file added by a commit is opened from the Commits node, the right-hand side of the diff is given
parentFilePath— areviewURI withbase: true.ReviewCommentController.provideCommentingRangesthen callsgetCommentingRanges(hunks, isBase: true), which builds ranges only fromDeletediff lines. An added file has none, so no commenting ranges are produced and the+never appears in the gutter. The extension log shows:The head side of the diff should use
filePathinstead. TheDELETEcase is left as it is: the content of a deleted file lives on the base side, and so does the comment.This has been the behavior since #2334, so it is not a recent regression.
Testing
New
src/test/view/treeNodes/gitFileChangeNode.test.tscovers both branches — that an added file is diffed against the head side, and that a deleted file keeps using the base side.Verified manually against a checked out pull request: added files under a commit in the Commits tree now offer the
+in the gutter and accept a comment.Note
I have a second change that builds on this one, for commenting on files from earlier commits of a pull request (refs #4315). Keeping it separate since this fix stands on its own.