Skip to content

Commit 9224064

Browse files
authored
SCM - add trace logging to the active repository controller to track down stale status bar items (microsoft#259804)
1 parent b3c7655 commit 9224064

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/vs/workbench/api/browser/mainThreadSCM.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { ITextModel } from '../../../editor/common/model.js';
3030
import { structuralEquals } from '../../../base/common/equals.js';
3131
import { historyItemBaseRefColor, historyItemRefColor, historyItemRemoteRefColor } from '../../contrib/scm/browser/scmHistory.js';
3232
import { ColorIdentifier } from '../../../platform/theme/common/colorUtils.js';
33+
import { ILogService } from '../../../platform/log/common/log.js';
3334

3435
function getIconFromIconDto(iconDto?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon): URI | { light: URI; dark: URI } | ThemeIcon | undefined {
3536
if (iconDto === undefined) {
@@ -312,6 +313,7 @@ class MainThreadSCMProvider implements ISCMProvider {
312313
private readonly _rootUri: URI | undefined,
313314
private readonly _iconPath: URI | { light: URI; dark: URI } | ThemeIcon | undefined,
314315
private readonly _inputBoxTextModel: ITextModel,
316+
private readonly _logService: ILogService,
315317
private readonly _quickDiffService: IQuickDiffService,
316318
private readonly _uriIdentService: IUriIdentityService,
317319
private readonly _workspaceContextService: IWorkspaceContextService
@@ -346,6 +348,8 @@ class MainThreadSCMProvider implements ISCMProvider {
346348
}
347349

348350
if (typeof features.statusBarCommands !== 'undefined') {
351+
this._logService.trace('[MainThreadSCMProvider][$updateSourceControl] rootUri: ', this.rootUri?.toString());
352+
this._logService.trace('[MainThreadSCMProvider][$updateSourceControl] statusBarCommands: ', features.statusBarCommands);
349353
this._statusBarCommands.set(features.statusBarCommands, undefined);
350354
}
351355

@@ -552,6 +556,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
552556
@ISCMService private readonly scmService: ISCMService,
553557
@ISCMViewService private readonly scmViewService: ISCMViewService,
554558
@ILanguageService private readonly languageService: ILanguageService,
559+
@ILogService private readonly logService: ILogService,
555560
@IModelService private readonly modelService: IModelService,
556561
@ITextModelService private readonly textModelService: ITextModelService,
557562
@IQuickDiffService private readonly quickDiffService: IQuickDiffService,
@@ -577,7 +582,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
577582
this._repositoryBarriers.set(handle, new Barrier());
578583

579584
const inputBoxTextModelRef = await this.textModelService.createModelReference(URI.revive(inputBoxDocumentUri));
580-
const provider = new MainThreadSCMProvider(this._proxy, handle, parentHandle, id, label, rootUri ? URI.revive(rootUri) : undefined, getIconFromIconDto(iconPath), inputBoxTextModelRef.object.textEditorModel, this.quickDiffService, this._uriIdentService, this.workspaceContextService);
585+
const provider = new MainThreadSCMProvider(this._proxy, handle, parentHandle, id, label, rootUri ? URI.revive(rootUri) : undefined, getIconFromIconDto(iconPath), inputBoxTextModelRef.object.textEditorModel, this.logService, this.quickDiffService, this._uriIdentService, this.workspaceContextService);
581586
const repository = this.scmService.registerSCMProvider(provider);
582587
this._repositories.set(handle, repository);
583588

src/vs/workbench/contrib/scm/browser/activity.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { autorun, autorunWithStore, derived, IObservable, observableFromEvent }
2424
import { observableConfigValue } from '../../../../platform/observable/common/platformObservableUtils.js';
2525
import { Command } from '../../../../editor/common/languages.js';
2626
import { ThemeIcon } from '../../../../base/common/themables.js';
27+
import { ILogService } from '../../../../platform/log/common/log.js';
2728

2829
const ActiveRepositoryContextKeys = {
2930
ActiveRepositoryName: new RawContextKey<string>('scmActiveRepositoryName', ''),
@@ -44,6 +45,7 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
4445
@IActivityService private readonly activityService: IActivityService,
4546
@IConfigurationService private readonly configurationService: IConfigurationService,
4647
@IContextKeyService private readonly contextKeyService: IContextKeyService,
48+
@ILogService private readonly logService: ILogService,
4749
@ISCMService private readonly scmService: ISCMService,
4850
@ISCMViewService private readonly scmViewService: ISCMViewService,
4951
@IStatusbarService private readonly statusbarService: IStatusbarService,
@@ -109,11 +111,16 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
109111
}));
110112

111113
this._register(autorunWithStore((reader, store) => {
114+
this.logService.trace('[SCMActiveRepositoryController][updateStatusBarAutorun] start');
112115
this._repositories.read(reader);
113116
const repository = this.scmViewService.activeRepository.read(reader);
114117
const commands = repository?.provider.statusBarCommands.read(reader);
115118

119+
this.logService.trace('[SCMActiveRepositoryController][updateStatusBarAutorun] commands: ', commands);
120+
this.logService.trace('[SCMActiveRepositoryController][updateStatusBarAutorun] repository: ', repository?.provider.rootUri?.toString());
121+
116122
this._updateStatusBar(repository, commands ?? [], store);
123+
this.logService.trace('[SCMActiveRepositoryController][updateStatusBarAutorun] end');
117124
}));
118125

119126
this._register(autorun(reader => {
@@ -139,6 +146,7 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
139146

140147
private _updateStatusBar(repository: ISCMRepository | undefined, commands: readonly Command[], store: DisposableStore): void {
141148
if (!repository) {
149+
this.logService.trace('[SCMActiveRepositoryController][_updateStatusBar] no active repository');
142150
return;
143151
}
144152

0 commit comments

Comments
 (0)