Skip to content

Commit a6c7270

Browse files
authored
SCM - fix issue with button state initialization (microsoft#199590)
1 parent 0dd6491 commit a6c7270

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ class SCMInputWidgetActionRunner extends ActionRunner {
17871787

17881788
constructor(
17891789
private readonly input: ISCMInput,
1790-
@IContextKeyService private readonly contextKeyService: IContextKeyService,
1790+
@IContextKeyService contextKeyService: IContextKeyService,
17911791
@IStorageService private readonly storageService: IStorageService
17921792
) {
17931793
super();
@@ -1797,11 +1797,6 @@ class SCMInputWidgetActionRunner extends ActionRunner {
17971797

17981798
protected override async runAction(action: IAction): Promise<void> {
17991799
try {
1800-
// Check if toolbar is disabled
1801-
if (this.contextKeyService.getContextKeyValue(SCMInputContextKeys.ActionIsEnabled.key) === false) {
1802-
return;
1803-
}
1804-
18051800
// Cancel previous action
18061801
if (this._ctxIsActionRunning.get() === true) {
18071802
this._cts?.cancel();
@@ -1899,7 +1894,7 @@ class SCMInputWidgetToolbar extends WorkbenchToolBar {
18991894
this._store.add(menu.onDidChange(() => updateToolbar()));
19001895

19011896
const ctxKeys = new Set<string>([SCMInputContextKeys.ActionIsEnabled.key, SCMInputContextKeys.ActionIsRunning.key]);
1902-
Event.filter(contextKeyService.onDidChangeContext, e => e.affectsSome(ctxKeys))(() => updateToolbar());
1897+
this._store.add(Event.filter(contextKeyService.onDidChangeContext, e => e.affectsSome(ctxKeys))(() => updateToolbar()));
19031898

19041899
// Delay initial update to finish class initialization
19051900
setTimeout(() => updateToolbar(), 0);
@@ -2127,6 +2122,7 @@ class SCMInputWidget {
21272122

21282123
const ctxIsActionEnabled = SCMInputContextKeys.ActionIsEnabled.bindTo(this.toolbarContextKeyService);
21292124
this.repositoryDisposables.add(input.repository.provider.onDidChangeResources(() => ctxIsActionEnabled.set(input.repository.provider.groups.some(r => r.resources.length > 0))));
2125+
ctxIsActionEnabled.set(input.repository.provider.groups.some(r => r.resources.length > 0));
21302126

21312127
const actionRunner = instantiationService2.createInstance(SCMInputWidgetActionRunner, input);
21322128
this.repositoryDisposables.add(actionRunner);

0 commit comments

Comments
 (0)