@@ -184,14 +184,15 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
184184 * Sync the tree view with the currently active PR overview
185185 */
186186 private async syncWithActivePullRequest ( pullRequest : PullRequestModel ) : Promise < void > {
187+ const alreadySelected = this . _view . selection . find ( child => child instanceof PRNode && ( child . pullRequestModel . number === pullRequest . number ) && ( child . pullRequestModel . remote . owner === pullRequest . remote . owner ) && ( child . pullRequestModel . remote . repositoryName === pullRequest . remote . repositoryName ) ) ;
188+ if ( alreadySelected || ! this . _view . visible ) {
189+ return ;
190+ }
187191 try {
188- // First expand the pull request in the tree to make sure it's visible
189- await this . expandPullRequest ( pullRequest ) ;
190-
191192 // Find the PR node in the tree and reveal it
192193 const prNode = await this . findPRNode ( pullRequest ) ;
193194 if ( prNode ) {
194- await this . reveal ( prNode , { select : true , focus : false , expand : true } ) ;
195+ await this . reveal ( prNode , { select : true , focus : false , expand : false } ) ;
195196 }
196197 } catch ( error ) {
197198 // Silently ignore errors to avoid disrupting the user experience
@@ -223,7 +224,7 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
223224 * Search for PR node within a workspace folder node
224225 */
225226 private async findPRNodeInWorkspaceFolder ( workspaceNode : WorkspaceFolderNode , pullRequest : PullRequestModel ) : Promise < PRNode | undefined > {
226- const children = await workspaceNode . getChildren ( ) ;
227+ const children = await workspaceNode . getChildren ( false ) ;
227228 for ( const child of children ) {
228229 if ( child instanceof CategoryTreeNode ) {
229230 const found = await this . findPRNodeInCategory ( child , pullRequest ) ;
@@ -237,9 +238,9 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
237238 * Search for PR node within a category node
238239 */
239240 private async findPRNodeInCategory ( categoryNode : CategoryTreeNode , pullRequest : PullRequestModel ) : Promise < PRNode | undefined > {
240- const children = await categoryNode . getChildren ( ) ;
241+ const children = await categoryNode . getChildren ( false ) ;
241242 for ( const child of children ) {
242- if ( child instanceof PRNode && child . pullRequestModel . number === pullRequest . number ) {
243+ if ( child instanceof PRNode && ( child . pullRequestModel . number === pullRequest . number ) && ( child . pullRequestModel . remote . owner === pullRequest . remote . owner ) && ( child . pullRequestModel . remote . repositoryName === pullRequest . remote . repositoryName ) ) {
243244 return child ;
244245 }
245246 }
0 commit comments