@@ -12,6 +12,7 @@ import Logger from '../common/logger';
1212import { ITelemetry } from '../common/telemetry' ;
1313import { fromPRUri , Schemes } from '../common/uri' ;
1414import { groupBy } from '../common/utils' ;
15+ import { PULL_REQUEST_OVERVIEW_VIEW_TYPE } from '../common/webview' ;
1516import { FolderRepositoryManager } from '../github/folderRepositoryManager' ;
1617import { GitHubRepository } from '../github/githubRepository' ;
1718import { GHPRComment , GHPRCommentThread , TemporaryComment } from '../github/prComment' ;
@@ -186,18 +187,35 @@ export class PullRequestCommentController extends CommentControllerBase implemen
186187 return tabs . filter ( tab => tab . input instanceof vscode . TabInputText || tab . input instanceof vscode . TabInputTextDiff ) . map ( tab => tab . input as vscode . TabInputText | vscode . TabInputTextDiff ) ;
187188 }
188189
190+ private prDescriptionOpened ( tabs : readonly vscode . Tab [ ] ) : boolean {
191+ return tabs . some ( tab => tab . input instanceof vscode . TabInputWebview && tab . label . includes ( `#${ this . pullRequestModel . number } ` ) && tab . input . viewType . includes ( PULL_REQUEST_OVERVIEW_VIEW_TYPE ) ) ;
192+ }
193+
189194 private async cleanClosedPrs ( ) {
190195 // Remove comments for which no editors belonging to the same PR are open
191196 const allPrEditors = await this . getPREditors ( this . allTabs ( ) ) ;
192- if ( allPrEditors . length === 0 ) {
197+ const prDescriptionOpened = this . prDescriptionOpened ( vscode . window . tabGroups . all . map ( group => group . tabs ) . flat ( ) ) ;
198+ if ( allPrEditors . length === 0 && ! prDescriptionOpened ) {
193199 this . removeAllCommentsThreads ( ) ;
194200 }
195201 }
196202
203+ private async openAllTextDocuments ( ) : Promise < vscode . TextDocument [ ] > {
204+ const files = await PullRequestModel . getChangeModels ( this . _folderRepoManager , this . pullRequestModel ) ;
205+ const textDocuments : vscode . TextDocument [ ] = [ ] ;
206+ for ( const file of files ) {
207+ textDocuments . push ( await vscode . workspace . openTextDocument ( file . filePath ) ) ;
208+ }
209+ return textDocuments ;
210+ }
211+
197212 private async onDidChangeOpenTabs ( e : vscode . TabChangeEvent ) : Promise < void > {
198213 const added = await this . getPREditors ( this . filterTabsToPrTabs ( e . opened ) ) ;
199214 if ( added . length ) {
200215 await this . addThreadsForEditors ( added ) ;
216+ } else if ( this . prDescriptionOpened ( e . opened ) ) {
217+ const textDocuments = await this . openAllTextDocuments ( ) ;
218+ await this . addThreadsForEditors ( textDocuments ) ;
201219 }
202220 if ( e . closed . length > 0 ) {
203221 // Delay cleaning closed editors to handle the case where a preview tab is replaced
0 commit comments