Skip to content

Commit 5d0484f

Browse files
committed
Fix renames
1 parent 3777b24 commit 5d0484f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/github/pullRequestModel.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,20 +1211,24 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
12111211
for (const change of changes) {
12121212
const uri = vscode.Uri.file(path.resolve(repository.rootUri.fsPath, change.uri.fsPath));
12131213
const fileName = change.uri.fsPath;
1214-
1214+
12151215
if (change.status === GitChangeType.ADD) {
12161216
// For added files, show against empty
12171217
const headUri = toReviewUri(uri, fileName, undefined, commitSha, false, { base: false }, repository.rootUri);
12181218
args.push([headUri, undefined, headUri]);
12191219
} else if (change.status === GitChangeType.DELETE) {
12201220
// For deleted files, show old version against empty
1221-
const baseFileName = change.status === GitChangeType.RENAME ? change.previousFileName : fileName;
1222-
const baseUri = toReviewUri(uri, baseFileName, undefined, commitSha + '~1', false, { base: true }, repository.rootUri);
1221+
const baseUri = toReviewUri(uri, fileName, undefined, commitSha + '~1', false, { base: true }, repository.rootUri);
12231222
args.push([uri, baseUri, undefined]);
1223+
} else if (change.status === GitChangeType.RENAME) {
1224+
// For renamed files, show old name against new name
1225+
const baseFileName = change.originalUri.fsPath;
1226+
const baseUri = toReviewUri(uri, baseFileName, undefined, commitSha + '~1', false, { base: true }, repository.rootUri);
1227+
const headUri = toReviewUri(uri, fileName, undefined, commitSha, false, { base: false }, repository.rootUri);
1228+
args.push([headUri, baseUri, headUri]);
12241229
} else {
12251230
// For modified files, show before and after
1226-
const baseFileName = change.status === GitChangeType.RENAME ? change.previousFileName : fileName;
1227-
const baseUri = toReviewUri(uri, baseFileName, undefined, commitSha + '~1', false, { base: true }, repository.rootUri);
1231+
const baseUri = toReviewUri(uri, fileName, undefined, commitSha + '~1', false, { base: true }, repository.rootUri);
12281232
const headUri = toReviewUri(uri, fileName, undefined, commitSha, false, { base: false }, repository.rootUri);
12291233
args.push([headUri, baseUri, headUri]);
12301234
}

0 commit comments

Comments
 (0)