Repository navigation
fix: allow file comments on deleted files (fixes #9207) - #9239
Open
Uong Dong Hung (hungud) wants to merge 2 commits into
Open
Uong Dong Hung (hungud) wants to merge 2 commits into
Uong Dong Hung (hungud) wants to merge 2 commits into
Conversation
When viewing the diff of a deleted file in a checked-out pull request,
provideCommentingRanges in ReviewCommentController evaluated
enableFileComments: ranges.length > 0. Because deleted files have no
lines on the modified side, ranges was empty and file comments were
rejected with "File comments are not allowed on this file".
Return { ranges: [], enableFileComments: true } when
matchedFile.status === GitChangeType.DELETE (matching the existing
GitChangeType.RENAME handling) and add a regression unit test.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Deleted-file diffs opened from Files changed still leave Add File Comment disabled because their review URIs are not handled, and the regression test does not use the actual URI construction.
1 open issue
What changed in this PR
This PR aims to fix #9207 by allowing file-level comments on deleted files in checked-out pull requests.
Changes:
- Enables file comments for deletions in the local-repository commenting-range branch.
- Adds a regression test and allows the test helper to create file changes with different statuses.
| File | Description |
|---|---|
src/view/reviewCommentController.ts |
Adds a deletion-specific return enabling file comments without line ranges. |
src/test/view/reviewCommentController.test.ts |
Parameterizes the helper’s change status and tests file-comment availability for deletions. |
Review effort: Balanced
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.

Fixes #9207
Problem
When checking out a pull request and clicking Add File Comment on a deleted file's diff, VS Code showed
"File comments are not allowed on this file."even though line comments on the deleted lines still worked.In
ReviewCommentController.provideCommentingRanges(src/view/reviewCommentController.ts), the local-repository branch returnedenableFileComments: ranges.length > 0. Since a deleted file has no new lines on the modified side,rangeswas empty ([]) andenableFileCommentsevaluated tofalse.Changes
GitChangeType.DELETEinReviewCommentController.provideCommentingRangesby returning{ ranges: [], enableFileComments: true }, consistent with the existingGitChangeType.RENAMEhandling.src/test/view/reviewCommentController.test.tsverifyingenableFileComments: truefor deleted files.Verification & QA Proof
npx tsc -p tsconfig.json --noEmitandnpx tsc -p tsconfig.test.json --noEmitwith zero errors.Before Fix (Red Test & VS Code Error)
After Fix (Green Test & VS Code File Comment Enabled)