@@ -224,8 +224,9 @@ export class SCMActiveRepositoryContextKeyController implements IWorkbenchContri
224
224
private activeRepositoryNameContextKey : IContextKey < string > ;
225
225
private activeRepositoryBranchNameContextKey : IContextKey < string > ;
226
226
227
+ private focusedRepository : ISCMRepository | undefined = undefined ;
228
+ private focusDisposable : IDisposable = Disposable . None ;
227
229
private readonly disposables = new DisposableStore ( ) ;
228
- private readonly focusedRepositoryDisposables = new DisposableStore ( ) ;
229
230
230
231
constructor (
231
232
@IContextKeyService contextKeyService : IContextKeyService ,
@@ -254,28 +255,25 @@ export class SCMActiveRepositoryContextKeyController implements IWorkbenchContri
254
255
return ;
255
256
}
256
257
257
- const activeResourceRepository = Iterable . find (
258
- this . scmViewService . visibleRepositories ,
258
+ const repository = Iterable . find (
259
+ this . scmViewService . repositories ,
259
260
r => Boolean ( r . provider . rootUri && this . uriIdentityService . extUri . isEqualOrParent ( activeResource , r . provider . rootUri ) )
260
261
) ;
261
262
262
- this . onDidFocusRepository ( activeResourceRepository ) ;
263
+ this . onDidFocusRepository ( repository ) ;
263
264
}
264
265
265
266
private onDidFocusRepository ( repository : ISCMRepository | undefined ) : void {
266
- this . focusedRepositoryDisposables . clear ( ) ;
267
-
268
- if ( ! repository ) {
267
+ if ( ! repository || this . focusedRepository === repository ) {
269
268
return ;
270
269
}
271
270
272
- this . focusedRepositoryDisposables . add ( repository . provider . onDidChangeHistoryProvider ( ( ) => {
273
- if ( repository . provider . historyProvider ) {
274
- this . focusedRepositoryDisposables . add ( repository . provider . historyProvider . onDidChangeCurrentHistoryItemGroup ( ( ) => this . updateContextKeys ( repository ) ) ) ;
275
- }
271
+ this . focusDisposable . dispose ( ) ;
272
+ this . focusedRepository = repository ;
276
273
277
- this . updateContextKeys ( repository ) ;
278
- } ) ) ;
274
+ if ( repository && repository . provider . onDidChangeStatusBarCommands ) {
275
+ this . focusDisposable = repository . provider . onDidChangeStatusBarCommands ( ( ) => this . updateContextKeys ( repository ) ) ;
276
+ }
279
277
280
278
this . updateContextKeys ( repository ) ;
281
279
}
@@ -284,6 +282,11 @@ export class SCMActiveRepositoryContextKeyController implements IWorkbenchContri
284
282
this . activeRepositoryNameContextKey . set ( repository ?. provider . name ?? '' ) ;
285
283
this . activeRepositoryBranchNameContextKey . set ( repository ?. provider . historyProvider ?. currentHistoryItemGroup ?. label ?? '' ) ;
286
284
}
285
+
286
+ dispose ( ) : void {
287
+ this . focusDisposable . dispose ( ) ;
288
+ this . disposables . dispose ( ) ;
289
+ }
287
290
}
288
291
289
292
export class SCMActiveResourceContextKeyController implements IWorkbenchContribution {
0 commit comments