From 6180a7f4d51d8b94d34d23fb8aa724e021aeee3f Mon Sep 17 00:00:00 2001 From: wahidsaeed Date: Mon, 3 Aug 2026 19:42:14 +0200 Subject: [PATCH] Fix Disable button dropdown for workspace-enabled-override extensions When an extension is disabled globally and then enabled just for the current workspace, DisableGloballyAction was still reporting itself as enabled, causing the Disable button to show a redundant dropdown with both "Disable" and "Disable (Workspace)". Only the workspace action is meaningful in that state since the extension is already disabled globally. Fixes #244138 --- .../extensions/browser/extensionsActions.ts | 3 ++- .../extensionsActions.test.ts | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts index 83d083905d20c6..af5d9f172d5ba4 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts @@ -1779,7 +1779,8 @@ export class DisableGloballyAction extends ExtensionAction { return; } this.enabled = this.extension.state === ExtensionState.Installed - && (this.extension.enablementState === EnablementState.EnabledGlobally || this.extension.enablementState === EnablementState.EnabledWorkspace) + && (this.extension.enablementState === EnablementState.EnabledGlobally + || (this.extension.enablementState === EnablementState.EnabledWorkspace && !this.extensionEnablementService.isDisabledGlobally(this.extension.local))) && this.extensionEnablementService.canChangeEnablement(this.extension.local); } } diff --git a/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsActions.test.ts b/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsActions.test.ts index f27872132feffd..b323396058a4db 100644 --- a/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsActions.test.ts +++ b/src/vs/workbench/contrib/extensions/test/electron-browser/extensionsActions.test.ts @@ -916,6 +916,28 @@ suite('ExtensionsActions', () => { }); }); + test('Test DisableGloballyAction when extension is disabled globally and enabled for workspace', () => { + const local = aLocalExtension('a'); + instantiationService.stub(IExtensionService, { + extensions: [toExtensionDescription(local)], + onDidChangeExtensions: Event.None, + whenInstalledExtensionsRegistered: () => Promise.resolve(true) + }); + + return instantiationService.get(IWorkbenchExtensionEnablementService).setEnablement([local], EnablementState.DisabledGlobally) + .then(() => instantiationService.get(IWorkbenchExtensionEnablementService).setEnablement([local], EnablementState.EnabledWorkspace)) + .then(() => { + instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', [local]); + + return instantiationService.get(IExtensionsWorkbenchService).queryLocal() + .then(extensions => { + const testObject: ExtensionsActions.DisableGloballyAction = disposables.add(instantiationService.createInstance(ExtensionsActions.DisableGloballyAction)); + testObject.extension = extensions[0]; + assert.ok(!testObject.enabled); + }); + }); + }); + test('Test DisableGloballyAction when extension is uninstalled', () => { const gallery = aGalleryExtension('a'); instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage(gallery));