diff --git a/src/common/diffHunk.ts b/src/common/diffHunk.ts index 13ded80c4f..7559cc47d1 100644 --- a/src/common/diffHunk.ts +++ b/src/common/diffHunk.ts @@ -355,7 +355,7 @@ export async function parseDiff( continue; } - const diffHunks = review.patch ? parsePatch(review.patch) : []; + const diffHunks = review.patch ? parsePatch(review.patch) : undefined; fileChanges.push( new InMemFileChange( parentCommit, @@ -364,7 +364,7 @@ export async function parseDiff( review.previous_filename, review.patch ?? '', diffHunks, - review.blob_url, + review.blob_url ), ); } diff --git a/src/common/file.ts b/src/common/file.ts index c352a24137..13d201cfcd 100644 --- a/src/common/file.ts +++ b/src/common/file.ts @@ -30,9 +30,9 @@ export class InMemFileChange implements SimpleFileChange { public readonly fileName: string, public readonly previousFileName: string | undefined, public readonly patch: string, - public readonly diffHunks: DiffHunk[], + public readonly diffHunks: DiffHunk[] | undefined, public readonly blobUrl: string, - ) {} + ) { } } export class SlimFileChange implements SimpleFileChange { @@ -42,5 +42,5 @@ export class SlimFileChange implements SimpleFileChange { public readonly status: GitChangeType, public readonly fileName: string, public readonly previousFileName: string | undefined, - ) {} + ) { } } diff --git a/src/view/fileChangeModel.ts b/src/view/fileChangeModel.ts index 0af6a60f68..cee4923308 100644 --- a/src/view/fileChangeModel.ts +++ b/src/view/fileChangeModel.ts @@ -51,7 +51,7 @@ export abstract class FileChangeModel { async diffHunks(): Promise { let diffHunks: DiffHunk[] = []; - if (this.change instanceof InMemFileChange) { + if (this.change instanceof InMemFileChange && this.change.diffHunks) { return this.change.diffHunks; } else if (this.status !== GitChangeType.RENAME) { try {