Skip to content

Commit e0599e4

Browse files
committed
#85036 Support multiple extension kinds
1 parent 1bd3750 commit e0599e4

File tree

3 files changed

+67
-20
lines changed

3 files changed

+67
-20
lines changed

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

+43-17
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import { alert } from 'vs/base/browser/ui/aria/aria';
5454
import { coalesce } from 'vs/base/common/arrays';
5555
import { IWorkbenchThemeService, COLOR_THEME_SETTING, ICON_THEME_SETTING, IFileIconTheme, IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService';
5656
import { ILabelService } from 'vs/platform/label/common/label';
57-
import { prefersExecuteOnUI } from 'vs/workbench/services/extensions/common/extensionsUtil';
57+
import { prefersExecuteOnUI, prefersExecuteOnWorkspace } from 'vs/workbench/services/extensions/common/extensionsUtil';
5858
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
5959
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
6060
import { IProductService } from 'vs/platform/product/common/productService';
@@ -1195,7 +1195,9 @@ export class ReloadAction extends ExtensionAction {
11951195
@IHostService private readonly hostService: IHostService,
11961196
@IExtensionService private readonly extensionService: IExtensionService,
11971197
@IExtensionEnablementService private readonly extensionEnablementService: IExtensionEnablementService,
1198-
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService
1198+
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
1199+
@IProductService private readonly productService: IProductService,
1200+
@IConfigurationService private readonly configurationService: IConfigurationService,
11991201
) {
12001202
super('extensions.reload', localize('reloadAction', "Reload"), ReloadAction.DisabledClass, false);
12011203
this._register(this.extensionService.onDidChangeExtensions(this.updateRunningExtensions, this));
@@ -1246,19 +1248,37 @@ export class ReloadAction extends ExtensionAction {
12461248
// Extension is running
12471249
if (runningExtension) {
12481250
if (isEnabled) {
1249-
if (!this.extensionService.canAddExtension(toExtensionDescription(this.extension.local))) {
1250-
if (isSameExtensionRunning) {
1251-
if (this.extension.version !== runningExtension.version) {
1251+
// No Reload is required if extension can run without reload
1252+
if (this.extensionService.canAddExtension(toExtensionDescription(this.extension.local))) {
1253+
return;
1254+
}
1255+
if (isSameExtensionRunning) {
1256+
// Different version of same extension is running. Requires reload to run the current version
1257+
if (this.extension.version !== runningExtension.version) {
1258+
this.enabled = true;
1259+
this.label = localize('reloadRequired', "Reload Required");
1260+
this.tooltip = localize('postUpdateTooltip', "Please reload Visual Studio Code to enable the updated extension.");
1261+
}
1262+
} else {
1263+
const runningExtensionServer = this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation);
1264+
if (this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && runningExtensionServer === this.extensionManagementServerService.remoteExtensionManagementServer) {
1265+
// This extension prefers to run on UI/Local side but is running in remote
1266+
if (prefersExecuteOnUI(this.extension.local!.manifest, this.productService, this.configurationService)) {
12521267
this.enabled = true;
12531268
this.label = localize('reloadRequired', "Reload Required");
1254-
this.tooltip = localize('postUpdateTooltip', "Please reload Visual Studio Code to enable the updated extension.");
1269+
this.tooltip = localize('postEnableTooltip', "Please reload Visual Studio Code to enable this extension.");
1270+
}
1271+
}
1272+
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer && runningExtensionServer === this.extensionManagementServerService.localExtensionManagementServer) {
1273+
// This extension prefers to run on Workspace/Remote side but is running in local
1274+
if (prefersExecuteOnWorkspace(this.extension.local!.manifest, this.productService, this.configurationService)) {
1275+
this.enabled = true;
1276+
this.label = localize('reloadRequired', "Reload Required");
1277+
this.tooltip = localize('postEnableTooltip', "Please reload Visual Studio Code to enable this extension.");
12551278
}
1256-
} else {
1257-
this.enabled = true;
1258-
this.label = localize('reloadRequired', "Reload Required");
1259-
this.tooltip = localize('postEnableTooltip', "Please reload Visual Studio Code to enable this extension.");
12601279
}
12611280
}
1281+
return;
12621282
} else {
12631283
if (isSameExtensionRunning) {
12641284
this.enabled = true;
@@ -2632,7 +2652,9 @@ export class SystemDisabledWarningAction extends ExtensionAction {
26322652
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService,
26332653
@ILabelService private readonly labelService: ILabelService,
26342654
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
2635-
@IExtensionService private readonly extensionService: IExtensionService
2655+
@IExtensionService private readonly extensionService: IExtensionService,
2656+
@IProductService private readonly productService: IProductService,
2657+
@IConfigurationService private readonly configurationService: IConfigurationService,
26362658
) {
26372659
super('extensions.install', '', `${SystemDisabledWarningAction.CLASS} hide`, false);
26382660
this._register(this.labelService.onDidChangeFormatters(() => this.update(), this));
@@ -2674,18 +2696,22 @@ export class SystemDisabledWarningAction extends ExtensionAction {
26742696
this.tooltip = localize('Install in other server to enable', "Install the extension on '{0}' to enable.", server.label);
26752697
return;
26762698
}
2677-
const runningExtension = this._runningExtensions.filter(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension!.identifier))[0];
2678-
const runningExtensionServer = runningExtension ? this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation) : null;
2679-
if (this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && runningExtensionServer === this.extensionManagementServerService.remoteExtensionManagementServer) {
2699+
}
2700+
const runningExtension = this._runningExtensions.filter(e => areSameExtensions({ id: e.identifier.value, uuid: e.uuid }, this.extension!.identifier))[0];
2701+
const runningExtensionServer = runningExtension ? this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation) : null;
2702+
if (this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && runningExtensionServer === this.extensionManagementServerService.remoteExtensionManagementServer) {
2703+
if (prefersExecuteOnWorkspace(this.extension.local!.manifest, this.productService, this.configurationService)) {
26802704
this.class = `${SystemDisabledWarningAction.INFO_CLASS}`;
26812705
this.tooltip = localize('disabled locally', "Extension is enabled on '{0}' and disabled locally.", this.extensionManagementServerService.remoteExtensionManagementServer.label);
2682-
return;
26832706
}
2684-
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer && runningExtensionServer === this.extensionManagementServerService.localExtensionManagementServer) {
2707+
return;
2708+
}
2709+
if (this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer && runningExtensionServer === this.extensionManagementServerService.localExtensionManagementServer) {
2710+
if (prefersExecuteOnUI(this.extension.local!.manifest, this.productService, this.configurationService)) {
26852711
this.class = `${SystemDisabledWarningAction.INFO_CLASS}`;
26862712
this.tooltip = localize('disabled remotely', "Extension is enabled locally and disabled on '{0}'.", this.extensionManagementServerService.remoteExtensionManagementServer.label);
2687-
return;
26882713
}
2714+
return;
26892715
}
26902716
}
26912717

src/vs/workbench/services/extensionManagement/common/extensionEnablementService.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,20 @@ export class ExtensionEnablementService extends Disposable implements IExtension
147147

148148
private _isDisabledByExtensionKind(extension: IExtension): boolean {
149149
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
150-
const extensionKind = getExtensionKind(extension.manifest, this.productService, this.configurationService);
151-
const server = extensionKind[0] === 'ui' ? this.extensionManagementServerService.localExtensionManagementServer : this.extensionManagementServerService.remoteExtensionManagementServer;
152-
return this.extensionManagementServerService.getExtensionManagementServer(extension.location) !== server;
150+
const server = this.extensionManagementServerService.getExtensionManagementServer(extension.location);
151+
for (const extensionKind of getExtensionKind(extension.manifest, this.productService, this.configurationService)) {
152+
if (extensionKind === 'ui') {
153+
if (server === this.extensionManagementServerService.localExtensionManagementServer) {
154+
return false;
155+
}
156+
}
157+
if (extensionKind === 'workspace') {
158+
if (server === this.extensionManagementServerService.remoteExtensionManagementServer) {
159+
return false;
160+
}
161+
}
162+
}
163+
return true;
153164
}
154165
return false;
155166
}

src/vs/workbench/services/extensions/common/extensionsUtil.ts

+10
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,21 @@ export function prefersExecuteOnUI(manifest: IExtensionManifest, productService:
1515
return (extensionKind.length > 0 && extensionKind[0] === 'ui');
1616
}
1717

18+
export function prefersExecuteOnWorkspace(manifest: IExtensionManifest, productService: IProductService, configurationService: IConfigurationService): boolean {
19+
const extensionKind = getExtensionKind(manifest, productService, configurationService);
20+
return (extensionKind.length > 0 && extensionKind[0] === 'workspace');
21+
}
22+
1823
export function canExecuteOnUI(manifest: IExtensionManifest, productService: IProductService, configurationService: IConfigurationService): boolean {
1924
const extensionKind = getExtensionKind(manifest, productService, configurationService);
2025
return extensionKind.some(kind => kind === 'ui');
2126
}
2227

28+
export function canExecuteOnWorkspace(manifest: IExtensionManifest, productService: IProductService, configurationService: IConfigurationService): boolean {
29+
const extensionKind = getExtensionKind(manifest, productService, configurationService);
30+
return extensionKind.some(kind => kind === 'workspace');
31+
}
32+
2333
export function canExecuteOnWeb(manifest: IExtensionManifest, productService: IProductService, configurationService: IConfigurationService): boolean {
2434
const extensionKind = getExtensionKind(manifest, productService, configurationService);
2535
return extensionKind.some(kind => kind === 'web');

0 commit comments

Comments
 (0)