Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when adding file comment to renamed file w/o other changes #6538

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/view/reviewCommentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DiffSide, IReviewThread, SubjectType } from '../common/comment';
import { getCommentingRanges } from '../common/commentingRanges';
import { mapNewPositionToOld, mapOldPositionToNew } from '../common/diffPositionMapping';
import { commands, contexts } from '../common/executeCommands';
import { GitChangeType } from '../common/file';
import { GitChangeType, InMemFileChange } from '../common/file';
import { disposeAll } from '../common/lifecycle';
import Logger from '../common/logger';
import { PR_SETTINGS_NAMESPACE, PULL_BRANCH, PULL_PR_BRANCH_BEFORE_CHECKOUT, PullPRBranchVariants } from '../common/settingKeys';
Expand Down Expand Up @@ -504,7 +504,7 @@ export class ReviewCommentController extends CommentControllerBase implements Co
const diffHunks = await matchedFile.changeModel.diffHunks();
if ((matchedFile.status === GitChangeType.RENAME) && (diffHunks.length === 0)) {
Logger.debug('No commenting ranges: File was renamed with no diffs.', ReviewCommentController.ID);
return;
return { ranges: [], enableFileComments: true };
}

const contentDiff = await this.getContentDiff(document.uri, matchedFile.fileName);
Expand Down Expand Up @@ -599,7 +599,9 @@ export class ReviewCommentController extends CommentControllerBase implements Co
}

if (fileChange.fileName !== query.path) {
return false;
if (!((fileChange.change instanceof InMemFileChange) && fileChange.change.previousFileName === query.path)) {
return false;
}
}

if (fileChange.filePath.scheme !== 'review') {
Expand Down