@@ -64,6 +64,12 @@ export class ReviewManager implements vscode.DecorationProvider {
6464 // todo, validate state only when state changes.
6565 this . updateState ( ) ;
6666 } ) ) ;
67+
68+ this . _disposables . push ( vscode . commands . registerCommand ( 'pr.refreshChanges' , _ => {
69+ this . updateComments ( ) ;
70+ this . prFileChangesProvider . refresh ( ) ;
71+ } ) ) ;
72+
6773 this . _prsTreeDataProvider = new PullRequestsTreeDataProvider ( this . _configuration , _repository , _prManager ) ;
6874 this . _disposables . push ( this . _prsTreeDataProvider ) ;
6975 this . _disposables . push ( vscode . window . registerDecorationProvider ( this ) ) ;
@@ -220,10 +226,14 @@ export class ReviewManager implements vscode.DecorationProvider {
220226 } ) ;
221227
222228 matchedFile . comments . push ( comment ) ;
229+ this . _comments . push ( comment ) ;
230+
231+ this . _onDidChangeCommentThreads . fire ( {
232+ added : [ ] ,
233+ changed : [ thread ] ,
234+ removed : [ ]
235+ } ) ;
223236
224- setTimeout ( ( ) => {
225- this . updateComments ( ) ;
226- } , 0 ) ;
227237 return thread ;
228238 } catch ( e ) {
229239 throw new Error ( formatError ( e ) ) ;
@@ -257,16 +267,19 @@ export class ReviewManager implements vscode.DecorationProvider {
257267
258268 let commentThread : vscode . CommentThread = {
259269 threadId : comment . commentId ,
260- resource : uri ,
270+ resource : vscode . Uri . file ( path . resolve ( this . _repository . path , rawComment . path ) ) ,
261271 range : range ,
262272 comments : [ comment ]
263273 } ;
264274
265275 matchedFile . comments . push ( rawComment ) ;
276+ this . _comments . push ( rawComment ) ;
266277
267- setTimeout ( ( ) => {
268- this . updateComments ( ) ;
269- } , 0 ) ;
278+ this . _onDidChangeCommentThreads . fire ( {
279+ added : [ commentThread ] ,
280+ changed : [ ] ,
281+ removed : [ ]
282+ } ) ;
270283
271284 return commentThread ;
272285 } catch ( e ) {
@@ -361,6 +374,11 @@ export class ReviewManager implements vscode.DecorationProvider {
361374 } ) ;
362375
363376 this . _comments = comments ;
377+ this . _localFileChanges . forEach ( change => {
378+ if ( change instanceof FileChangeNode ) {
379+ change . comments = this . _comments . filter ( comment => change . fileName === comment . path && comment . position !== null ) ;
380+ }
381+ } ) ;
364382 this . _onDidChangeDecorations . fire ( ) ;
365383 }
366384
0 commit comments