-
Notifications
You must be signed in to change notification settings - Fork 37.2k
fix: prevent duplicate disable actions in extension dropdown #285636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: prevent duplicate disable actions in extension dropdown #285636
Conversation
When an extension is disabled globally but enabled in the workspace, the 'Disable' (Global) action was still enabled in the dropdown menu, leading to both 'Disable' and 'Disable (Workspace)' being visible. Clicking 'Disable' had no effect as it was already disabled globally. This change ensures 'Disable' action is only enabled if the extension is NOT already disabled globally. Fixes microsoft#244138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the extension dropdown menu where the "Disable" action was incorrectly shown when an extension was already disabled globally but had a workspace override to enable it (EnabledWorkspace state).
Key Changes:
- Added an explicit check using
isDisabledGlobally()to theDisableGloballyAction.update()method to prevent the action from being enabled when the extension is already disabled globally
| if (this.extension && this.extension.local && !this.extension.isWorkspaceScoped && this.extensionService.extensions.some(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension!.identifier))) { | ||
| this.enabled = this.extension.state === ExtensionState.Installed | ||
| && (this.extension.enablementState === EnablementState.EnabledGlobally || this.extension.enablementState === EnablementState.EnabledWorkspace) | ||
| && !this.extensionEnablementService.isDisabledGlobally(this.extension.local) |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix addresses the scenario where an extension is disabled globally but has a workspace override to enable it (i.e., enablementState is EnabledWorkspace). However, there doesn't appear to be a test case in the test suite that covers this specific scenario. Consider adding a test case similar to the existing ones in extensionsActions.test.ts that:
- Disables an extension globally using setEnablement with EnablementState.DisabledGlobally
- Then enables it for workspace using setEnablement with EnablementState.EnabledWorkspace
- Verifies that DisableGloballyAction is disabled in this state
This would ensure the fix continues to work correctly in the future.
Add test case for DisableGloballyAction when an extension is disabled globally but has a workspace override to enable it. This ensures the action remains disabled in this edge case.
huangxinyue8616
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary
When an extension is in the state:
The "Disable" button dropdown would show both:
The "Disable" action (global) should not be shown because the extension is already disabled globally. The "Disable (Workspace)" action is the correct one to disable the workspace override.
Change
Modified
DisableGloballyAction.update()insrc/vs/workbench/contrib/extensions/browser/extensionsActions.tsto explicitly check if the extension is already disabled globally.If it is already disabled globally, the action becomes disabled.
Fixes #244138