Skip to content

Commit c061693

Browse files
authored
1 parent 4ba524c commit c061693

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { EnablementState, IExtensionManagementServerService, IWorkbenchExtension
1313
import { IExtensionIgnoredRecommendationsService, IExtensionRecommendationsService } from 'vs/workbench/services/extensionRecommendations/common/extensionRecommendations';
1414
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions';
1515
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
16-
import { VIEWLET_ID, IExtensionsWorkbenchService, IExtensionsViewPaneContainer, TOGGLE_IGNORE_EXTENSION_ACTION_ID, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID, IWorkspaceRecommendedExtensionsView, AutoUpdateConfigurationKey, HasOutdatedExtensionsContext, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID, ExtensionEditorTab, THEME_ACTIONS_GROUP, INSTALL_ACTIONS_GROUP, OUTDATED_EXTENSIONS_VIEW_ID, CONTEXT_HAS_GALLERY, IExtension, extensionsSearchActionsMenu, UPDATE_ACTIONS_GROUP } from 'vs/workbench/contrib/extensions/common/extensions';
16+
import { VIEWLET_ID, IExtensionsWorkbenchService, IExtensionsViewPaneContainer, TOGGLE_IGNORE_EXTENSION_ACTION_ID, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID, IWorkspaceRecommendedExtensionsView, AutoUpdateConfigurationKey, HasOutdatedExtensionsContext, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID, ExtensionEditorTab, THEME_ACTIONS_GROUP, INSTALL_ACTIONS_GROUP, OUTDATED_EXTENSIONS_VIEW_ID, CONTEXT_HAS_GALLERY, IExtension, extensionsSearchActionsMenu, UPDATE_ACTIONS_GROUP, IExtensionArg } from 'vs/workbench/contrib/extensions/common/extensions';
1717
import { ReinstallAction, InstallSpecificVersionOfExtensionAction, ConfigureWorkspaceRecommendedExtensionsAction, ConfigureWorkspaceFolderRecommendedExtensionsAction, PromptExtensionInstallFailureAction, SearchExtensionsAction, SetColorThemeAction, SetFileIconThemeAction, SetProductIconThemeAction, ClearLanguageAction, ToggleAutoUpdateForExtensionAction, ToggleAutoUpdatesForPublisherAction, TogglePreReleaseExtensionAction } from 'vs/workbench/contrib/extensions/browser/extensionsActions';
1818
import { ExtensionsInput } from 'vs/workbench/contrib/extensions/common/extensionsInput';
1919
import { ExtensionEditor } from 'vs/workbench/contrib/extensions/browser/extensionEditor';
@@ -80,6 +80,7 @@ import { IStringDictionary } from 'vs/base/common/collections';
8080
import { CONTEXT_KEYBINDINGS_EDITOR } from 'vs/workbench/contrib/preferences/common/preferences';
8181
import { DeprecatedExtensionsChecker } from 'vs/workbench/contrib/extensions/browser/deprecatedExtensionsChecker';
8282
import { ProgressLocation } from 'vs/platform/progress/common/progress';
83+
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
8384

8485
// Singletons
8586
registerSingleton(IExtensionsWorkbenchService, ExtensionsWorkbenchService, InstantiationType.Eager /* Auto updates extensions */);
@@ -1534,8 +1535,9 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
15341535
when: ContextKeyExpr.and(ContextKeyExpr.equals('extensionStatus', 'installed'), ContextKeyExpr.has('isDefaultApplicationScopedExtension').negate(), ContextKeyExpr.has('isBuiltinExtension').negate(), ContextKeyExpr.equals('isWorkspaceScopedExtension', false)),
15351536
order: 3
15361537
},
1537-
run: async (accessor: ServicesAccessor, id: string) => {
1538-
const extension = this.extensionsWorkbenchService.local.find(e => areSameExtensions({ id }, e.identifier));
1538+
run: async (accessor: ServicesAccessor, _: string, extensionArg: IExtensionArg) => {
1539+
const uriIdentityService = accessor.get(IUriIdentityService);
1540+
const extension = extensionArg.location ? this.extensionsWorkbenchService.installed.find(e => uriIdentityService.extUri.isEqual(e.local?.location, extensionArg.location)) : undefined;
15391541
if (extension) {
15401542
return this.extensionsWorkbenchService.toggleApplyExtensionToAllProfiles(extension);
15411543
}

src/vs/workbench/contrib/extensions/browser/extensionsActions.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Emitter, Event } from 'vs/base/common/event';
1212
import * as json from 'vs/base/common/json';
1313
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
1414
import { disposeIfDisposable } from 'vs/base/common/lifecycle';
15-
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewPaneContainer, IExtensionContainer, TOGGLE_IGNORE_EXTENSION_ACTION_ID, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, THEME_ACTIONS_GROUP, INSTALL_ACTIONS_GROUP, UPDATE_ACTIONS_GROUP, AutoUpdateConfigurationKey, AutoUpdateConfigurationValue, ExtensionEditorTab, ExtensionRuntimeActionType } from 'vs/workbench/contrib/extensions/common/extensions';
15+
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewPaneContainer, IExtensionContainer, TOGGLE_IGNORE_EXTENSION_ACTION_ID, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, THEME_ACTIONS_GROUP, INSTALL_ACTIONS_GROUP, UPDATE_ACTIONS_GROUP, AutoUpdateConfigurationKey, AutoUpdateConfigurationValue, ExtensionEditorTab, ExtensionRuntimeActionType, IExtensionArg } from 'vs/workbench/contrib/extensions/common/extensions';
1616
import { ExtensionsConfigurationInitialContent } from 'vs/workbench/contrib/extensions/common/extensionsFileTemplate';
1717
import { IGalleryExtension, IExtensionGalleryService, ILocalExtension, InstallOptions, InstallOperation, TargetPlatformToString, ExtensionManagementErrorCode } from 'vs/platform/extensionManagement/common/extensionManagement';
1818
import { IWorkbenchExtensionEnablementService, EnablementState, IExtensionManagementServerService, IExtensionManagementServer } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
@@ -1272,9 +1272,15 @@ export class MenuItemExtensionAction extends ExtensionAction {
12721272

12731273
override async run(): Promise<void> {
12741274
if (this.extension) {
1275-
await this.action.run(this.extension.local ? getExtensionId(this.extension.local.manifest.publisher, this.extension.local.manifest.name)
1275+
const id = this.extension.local ? getExtensionId(this.extension.local.manifest.publisher, this.extension.local.manifest.name)
12761276
: this.extension.gallery ? getExtensionId(this.extension.gallery.publisher, this.extension.gallery.name)
1277-
: this.extension.identifier.id);
1277+
: this.extension.identifier.id;
1278+
const extensionArg: IExtensionArg = {
1279+
id: this.extension.identifier.id,
1280+
version: this.extension.version,
1281+
location: this.extension.local?.location
1282+
};
1283+
await this.action.run(id, extensionArg);
12781284
}
12791285
}
12801286
}

src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,27 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
21502150
if (!extension.local || isApplicationScopedExtension(extension.local.manifest) || extension.isBuiltin) {
21512151
return;
21522152
}
2153-
await this.extensionManagementService.toggleAppliationScope(extension.local, this.userDataProfileService.currentProfile.extensionsResource);
2153+
const isApplicationScoped = extension.local.isApplicationScoped;
2154+
await Promise.all(this.getAllExtensions().map(async extensions => {
2155+
const local = extensions.local.find(e => areSameExtensions(e.identifier, extension.identifier))?.local;
2156+
if (local && local.isApplicationScoped === isApplicationScoped) {
2157+
await this.extensionManagementService.toggleAppliationScope(local, this.userDataProfileService.currentProfile.extensionsResource);
2158+
}
2159+
}));
2160+
}
2161+
2162+
private getAllExtensions(): Extensions[] {
2163+
const extensions: Extensions[] = [];
2164+
if (this.localExtensions) {
2165+
extensions.push(this.localExtensions);
2166+
}
2167+
if (this.remoteExtensions) {
2168+
extensions.push(this.remoteExtensions);
2169+
}
2170+
if (this.webExtensions) {
2171+
extensions.push(this.webExtensions);
2172+
}
2173+
return extensions;
21542174
}
21552175

21562176
private isInstalledExtensionSynced(extension: ILocalExtension): boolean {

src/vs/workbench/contrib/extensions/common/extensions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,9 @@ export const INSTALL_ACTIONS_GROUP = '0_install';
230230
export const UPDATE_ACTIONS_GROUP = '0_update';
231231

232232
export const extensionsSearchActionsMenu = new MenuId('extensionsSearchActionsMenu');
233+
234+
export interface IExtensionArg {
235+
id: string;
236+
version: string;
237+
location: URI | undefined;
238+
}

0 commit comments

Comments
 (0)