@@ -10,14 +10,14 @@ import { getDiffLineByPosition, getLastDiffLine, mapCommentsToHead, mapHeadLineT
1010import { toReviewUri , fromReviewUri } from '../common/uri' ;
1111import { groupBy , formatError } from '../common/utils' ;
1212import { Comment } from '../common/comment' ;
13- import { GitChangeType } from '../common/file' ;
13+ import { GitChangeType , SlimFileChange } from '../common/file' ;
1414import { GitErrorCodes } from '../common/gitError' ;
1515import { IPullRequestModel , IPullRequestManager } from '../github/interface' ;
1616import { Repository } from '../common/repository' ;
1717import { PullRequestChangesTreeDataProvider } from './prChangesTreeDataProvider' ;
1818import { GitContentProvider } from './gitContentProvider' ;
1919import { DiffChangeType } from '../common/diffHunk' ;
20- import { FileChangeNode } from './treeNodes/fileChangeNode' ;
20+ import { FileChangeNode , RemoteFileChangeNode , fileChangeNodeFilter } from './treeNodes/fileChangeNode' ;
2121import Logger from '../common/logger' ;
2222import { PullRequestsTreeDataProvider } from './prsTreeDataProvider' ;
2323import { Configuration } from '../configuration' ;
@@ -29,8 +29,8 @@ export class ReviewManager implements vscode.DecorationProvider {
2929 private _disposables : vscode . Disposable [ ] ;
3030
3131 private _comments : Comment [ ] = [ ] ;
32- private _localFileChanges : FileChangeNode [ ] = [ ] ;
33- private _obsoleteFileChanges : FileChangeNode [ ] = [ ] ;
32+ private _localFileChanges : ( FileChangeNode | RemoteFileChangeNode ) [ ] = [ ] ;
33+ private _obsoleteFileChanges : ( FileChangeNode | RemoteFileChangeNode ) [ ] = [ ] ;
3434 private _lastCommitSha : string ;
3535 private _updateMessageShown : boolean = false ;
3636 private _updateCurrentBranch : boolean = false ;
@@ -199,7 +199,7 @@ export class ReviewManager implements vscode.DecorationProvider {
199199 try {
200200 let uri = document . uri ;
201201 let fileName = uri . path ;
202- let matchedFiles = this . _localFileChanges . filter ( fileChange => {
202+ let matchedFiles = fileChangeNodeFilter ( this . _localFileChanges ) . filter ( fileChange => {
203203 if ( uri . scheme === 'review' ) {
204204 return fileChange . fileName === fileName ;
205205 } else {
@@ -356,8 +356,16 @@ export class ReviewManager implements vscode.DecorationProvider {
356356 await this . _prManager . fullfillPullRequestCommitInfo ( pr ) ;
357357 let baseSha = pr . base . sha ;
358358 let headSha = pr . head . sha ;
359- const richContentChanges = await parseDiff ( data , this . _repository , baseSha ) ;
360- this . _localFileChanges = richContentChanges . map ( change => {
359+ const contentChanges = await parseDiff ( data , this . _repository , baseSha ) ;
360+ this . _localFileChanges = contentChanges . map ( change => {
361+ if ( change instanceof SlimFileChange ) {
362+ return new RemoteFileChangeNode (
363+ pr ,
364+ change . status ,
365+ change . fileName ,
366+ change . blobUrl
367+ ) ;
368+ }
361369 let changedItem = new FileChangeNode (
362370 pr ,
363371 change . status ,
@@ -533,9 +541,9 @@ export class ReviewManager implements vscode.DecorationProvider {
533541 // local file, we only provide active comments
534542 // TODO. for comments in deleted ranges, they should show on top of the first line.
535543 const fileName = document . uri . fsPath ;
536- const matchedFiles = this . _localFileChanges . filter ( fileChange => path . resolve ( this . _repository . path , fileChange . fileName ) === fileName ) ;
544+ const matchedFiles = fileChangeNodeFilter ( this . _localFileChanges ) . filter ( fileChange => path . resolve ( this . _repository . path , fileChange . fileName ) === fileName ) ;
537545 if ( matchedFiles && matchedFiles . length ) {
538- const matchedFile = matchedFiles [ 0 ] ;
546+ const matchedFile : FileChangeNode = matchedFiles [ 0 ] ;
539547
540548 let contentDiff : string ;
541549 if ( document . isDirty ) {
@@ -674,10 +682,10 @@ export class ReviewManager implements vscode.DecorationProvider {
674682 this . _workspaceCommentProvider = vscode . workspace . registerWorkspaceCommentProvider ( {
675683 onDidChangeCommentThreads : this . _onDidChangeCommentThreads . event ,
676684 provideWorkspaceComments : async ( token : vscode . CancellationToken ) => {
677- const comments = await Promise . all ( this . _localFileChanges . map ( async fileChange => {
685+ const comments = await Promise . all ( fileChangeNodeFilter ( this . _localFileChanges ) . map ( async fileChange => {
678686 return this . commentsToCommentThreads ( fileChange . comments ) ;
679687 } ) ) ;
680- const outdatedComments = this . _obsoleteFileChanges . map ( fileChange => {
688+ const outdatedComments = fileChangeNodeFilter ( this . _obsoleteFileChanges ) . map ( fileChange => {
681689 return this . outdatedCommentsToCommentThreads ( fileChange , fileChange . comments ) ;
682690 } ) ;
683691 return [ ...comments , ...outdatedComments ] . reduce ( ( prev , curr ) => prev . concat ( curr ) , [ ] ) ;
@@ -686,9 +694,13 @@ export class ReviewManager implements vscode.DecorationProvider {
686694 } ) ;
687695 }
688696
689- private findMatchedFileChange ( fileChanges : FileChangeNode [ ] , uri : vscode . Uri ) {
697+ private findMatchedFileChange ( fileChanges : ( FileChangeNode | RemoteFileChangeNode ) [ ] , uri : vscode . Uri ) : FileChangeNode {
690698 let query = JSON . parse ( uri . query ) ;
691699 let matchedFiles = fileChanges . filter ( fileChange => {
700+ if ( fileChange instanceof RemoteFileChangeNode ) {
701+ return false ;
702+ }
703+
692704 if ( fileChange . fileName !== query . path ) {
693705 return false ;
694706 }
@@ -708,7 +720,7 @@ export class ReviewManager implements vscode.DecorationProvider {
708720 } ) ;
709721
710722 if ( matchedFiles && matchedFiles . length ) {
711- return matchedFiles [ 0 ] ;
723+ return matchedFiles [ 0 ] as FileChangeNode ;
712724 }
713725
714726 return null ;
@@ -790,7 +802,7 @@ export class ReviewManager implements vscode.DecorationProvider {
790802
791803 async provideTextDocumentContent ( uri : vscode . Uri ) : Promise < string > {
792804 let { path, commit } = fromReviewUri ( uri ) ;
793- let changedItems = this . _localFileChanges
805+ let changedItems = fileChangeNodeFilter ( this . _localFileChanges )
794806 . filter ( change => change . fileName === path )
795807 . filter ( fileChange => fileChange . sha === commit || ( fileChange . parentSha ? fileChange . parentSha : `${ fileChange . sha } ^` ) === commit ) ;
796808
@@ -801,7 +813,7 @@ export class ReviewManager implements vscode.DecorationProvider {
801813 return ret . reduce ( ( prev , curr ) => prev . concat ( ...curr ) , [ ] ) . join ( '\n' ) ;
802814 }
803815
804- changedItems = this . _obsoleteFileChanges
816+ changedItems = fileChangeNodeFilter ( this . _obsoleteFileChanges )
805817 . filter ( change => change . fileName === path )
806818 . filter ( fileChange => fileChange . sha === commit || ( fileChange . parentSha ? fileChange . parentSha : `${ fileChange . sha } ^` ) === commit ) ;
807819
0 commit comments