Skip to content

Fix commenting on added files in the Commits tree - #8866

Open
Artur Czuba (artur-czuba-iyuno) wants to merge 1 commit into
microsoft:mainfrom
artur-czuba-iyuno:fix-comment-added-file-commit-diff
Open

Fix commenting on added files in the Commits tree#8866
Artur Czuba (artur-czuba-iyuno) wants to merge 1 commit into
microsoft:mainfrom
artur-czuba-iyuno:fix-comment-added-file-commit-diff

Conversation

@artur-czuba-iyuno

Copy link
Copy Markdown

When a file added by a commit is opened from the Commits node, the right-hand side of the diff is given parentFilePath — 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. The extension log shows:

No commenting ranges: Diff is in base and none of the diff hunks could be added.

The head side of the diff should use filePath 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.

This has been the behavior since #2334, so it is not a recent regression.

Testing

New src/test/view/treeNodes/gitFileChangeNode.test.ts covers 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.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants