@@ -49,6 +49,7 @@ export interface SuggestionInformation {
49
49
50
50
export class ReviewCommentController extends CommentControllerBase implements CommentHandler , vscode . CommentingRangeProvider2 , CommentReactionHandler {
51
51
private static readonly ID = 'ReviewCommentController' ;
52
+ private static readonly PREFIX = 'github-review' ;
52
53
private _commentHandlerId : string ;
53
54
54
55
// Note: marked as protected so that tests can verify caches have been updated correctly without breaking type safety
@@ -73,7 +74,7 @@ export class ReviewCommentController extends CommentControllerBase implements Co
73
74
super ( folderRepoManager , telemetry ) ;
74
75
this . _context = this . _folderRepoManager . context ;
75
76
this . _commentController = this . _register ( vscode . comments . createCommentController (
76
- `github-review -${ folderRepoManager . activePullRequest ?. remote . owner } -${ folderRepoManager . activePullRequest ?. remote . owner } -${ folderRepoManager . activePullRequest ! . number } ` ,
77
+ `${ ReviewCommentController . PREFIX } -${ folderRepoManager . activePullRequest ?. remote . owner } -${ folderRepoManager . activePullRequest ?. remote . owner } -${ folderRepoManager . activePullRequest ! . number } ` ,
77
78
vscode . l10n . t ( 'Pull Request ({0})' , folderRepoManager . activePullRequest ! . title ) ,
78
79
) ) ;
79
80
this . _commentController . commentingRangeProvider = this as vscode . CommentingRangeProvider ;
@@ -345,7 +346,6 @@ export class ReviewCommentController extends CommentControllerBase implements Co
345
346
this . updateResourcesWithCommentingRanges ( ) ;
346
347
} ) ,
347
348
) ;
348
- this . _register ( vscode . window . onDidChangeActiveTextEditor ( e => this . onDidChangeActiveTextEditor ( e ) ) ) ;
349
349
}
350
350
351
351
private _findMatchingThread ( thread : IReviewThread ) : { threadMap : { [ key : string ] : GHPRCommentThread [ ] } , index : number } {
@@ -371,9 +371,19 @@ export class ReviewCommentController extends CommentControllerBase implements Co
371
371
}
372
372
373
373
private _commentContentChangedListener : vscode . Disposable | undefined ;
374
- private onDidChangeActiveTextEditor ( editor : vscode . TextEditor | undefined ) {
374
+ protected onDidChangeActiveTextEditor ( editor : vscode . TextEditor | undefined ) {
375
375
this . _commentContentChangedListener ?. dispose ( ) ;
376
376
this . _commentContentChangedListener = undefined ;
377
+
378
+ const activeTab = vscode . window . tabGroups . activeTabGroup . activeTab ;
379
+ const activeUri = activeTab ?. input instanceof vscode . TabInputText ? activeTab . input . uri : ( activeTab ?. input instanceof vscode . TabInputTextDiff ? activeTab . input . modified : undefined ) ;
380
+
381
+ if ( editor && activeUri && editor . document . uri . authority . startsWith ( ReviewCommentController . PREFIX ) && ( activeUri . scheme === Schemes . File ) ) {
382
+ if ( this . _folderRepoManager . activePullRequest && activeUri . toString ( ) . startsWith ( this . _repository . rootUri . toString ( ) ) ) {
383
+ this . tryAddCopilotMention ( editor , this . _folderRepoManager . activePullRequest ) ;
384
+ }
385
+ }
386
+
377
387
if ( editor ?. document . uri . scheme !== Schemes . Comment ) {
378
388
return ;
379
389
}
0 commit comments