Fix Microsoft/vscode-remote/issues/1564

This commit is contained in:
Sandeep Somavarapu 2019-04-24 15:51:22 +02:00
parent 240c3e88b3
commit 296fa84d8d
4 changed files with 41 additions and 19 deletions

View file

@ -83,6 +83,7 @@ export interface IExtensionsWorkbenchService {
_serviceBrand: any; _serviceBrand: any;
onChange: Event<IExtension | undefined>; onChange: Event<IExtension | undefined>;
local: IExtension[]; local: IExtension[];
installed: IExtension[];
outdated: IExtension[]; outdated: IExtension[];
queryLocal(server?: IExtensionManagementServer): Promise<IExtension[]>; queryLocal(server?: IExtensionManagementServer): Promise<IExtension[]>;
queryGallery(token: CancellationToken): Promise<IPager<IExtension>>; queryGallery(token: CancellationToken): Promise<IPager<IExtension>>;

View file

@ -328,9 +328,9 @@ export class RemoteInstallAction extends ExtensionAction {
// Installed User Extension // Installed User Extension
&& this.extension && this.extension.local && this.extension.type === ExtensionType.User && this.extension.state === ExtensionState.Installed && this.extension && this.extension.local && this.extension.type === ExtensionType.User && this.extension.state === ExtensionState.Installed
// Local Workspace Extension // Local Workspace Extension
&& this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && !isUIExtension(this.extension.local.manifest, this.configurationService) && this.extension.server === this.extensionManagementServerService.localExtensionManagementServer && (isLanguagePackExtension(this.extension.local.manifest) || !isUIExtension(this.extension.local.manifest, this.configurationService))
// Extension does not exist in remote // Extension does not exist in remote
&& !this.extensionsWorkbenchService.local.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.remoteExtensionManagementServer) && !this.extensionsWorkbenchService.installed.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.remoteExtensionManagementServer)
&& this.extensionsWorkbenchService.canInstall(this.extension) && this.extensionsWorkbenchService.canInstall(this.extension)
) { ) {
this.enabled = true; this.enabled = true;
@ -406,10 +406,10 @@ export class LocalInstallAction extends ExtensionAction {
if (this.environmentService.configuration.remoteAuthority if (this.environmentService.configuration.remoteAuthority
// Installed User Extension // Installed User Extension
&& this.extension && this.extension.local && this.extension.type === ExtensionType.User && this.extension.state === ExtensionState.Installed && this.extension && this.extension.local && this.extension.type === ExtensionType.User && this.extension.state === ExtensionState.Installed
// Remote UI Extension // Remote UI or Language pack Extension
&& this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer && isUIExtension(this.extension.local.manifest, this.configurationService) && this.extension.server === this.extensionManagementServerService.remoteExtensionManagementServer && (isLanguagePackExtension(this.extension.local.manifest) || isUIExtension(this.extension.local.manifest, this.configurationService))
// Extension does not exist in local // Extension does not exist in local
&& !this.extensionsWorkbenchService.local.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.localExtensionManagementServer) && !this.extensionsWorkbenchService.installed.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server === this.extensionManagementServerService.localExtensionManagementServer)
&& this.extensionsWorkbenchService.canInstall(this.extension) && this.extensionsWorkbenchService.canInstall(this.extension)
) { ) {
this.enabled = true; this.enabled = true;
@ -2660,14 +2660,14 @@ export class DisabledLabelAction extends ExtensionAction {
update(): void { update(): void {
this.class = `${DisabledLabelAction.Class} hide`; this.class = `${DisabledLabelAction.Class} hide`;
this.label = ''; this.label = '';
if (this.extension && this.extension.local && isLanguagePackExtension(this.extension.local.manifest)) {
return;
}
if (this.warningAction.tooltip) { if (this.warningAction.tooltip) {
this.class = DisabledLabelAction.Class; this.class = DisabledLabelAction.Class;
this.label = this.warningAction.tooltip; this.label = this.warningAction.tooltip;
return; return;
} }
if (this.extension && this.extension.local && isLanguagePackExtension(this.extension.local.manifest)) {
return;
}
if (this.extension && this.extension.local && this._runningExtensions) { if (this.extension && this.extension.local && this._runningExtensions) {
const isEnabled = this.extensionEnablementService.isEnabled(this.extension.local); const isEnabled = this.extensionEnablementService.isEnabled(this.extension.local);
const isExtensionRunning = this._runningExtensions.some(e => areSameExtensions({ id: e.identifier.value }, this.extension.identifier)); const isExtensionRunning = this._runningExtensions.some(e => areSameExtensions({ id: e.identifier.value }, this.extension.identifier));
@ -2728,11 +2728,19 @@ export class SystemDisabledWarningAction extends ExtensionAction {
!this._runningExtensions || !this._runningExtensions ||
!this.workbenchEnvironmentService.configuration.remoteAuthority || !this.workbenchEnvironmentService.configuration.remoteAuthority ||
!this.extensionManagementServerService.remoteExtensionManagementServer || !this.extensionManagementServerService.remoteExtensionManagementServer ||
this.extension.state !== ExtensionState.Installed || this.extension.state !== ExtensionState.Installed
isLanguagePackExtension(this.extension.local.manifest)
) { ) {
return; return;
} }
if (isLanguagePackExtension(this.extension.local.manifest)) {
if (!this.extensionsWorkbenchService.installed.some(e => areSameExtensions(e.identifier, this.extension.identifier) && e.server !== this.extension.server)) {
this.class = `${SystemDisabledWarningAction.INFO_CLASS}`;
this.tooltip = this.extension.server === this.extensionManagementServerService.localExtensionManagementServer
? localize('Install language pack also in remote server', "Install the language pack extension on '{0}' to enable it also there.", this.getServerLabel(this.extensionManagementServerService.remoteExtensionManagementServer))
: localize('Install language pack also locally', "Install the extension locally to enable it also there.");
}
return;
}
const runningExtension = this._runningExtensions.filter(e => areSameExtensions({ id: e.identifier.value }, this.extension.identifier))[0]; const runningExtension = this._runningExtensions.filter(e => areSameExtensions({ id: e.identifier.value }, this.extension.identifier))[0];
const runningExtensionServer = runningExtension ? this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation) : null; const runningExtensionServer = runningExtension ? this.extensionManagementServerService.getExtensionManagementServer(runningExtension.extensionLocation) : null;
const localExtension = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, this.extension.identifier))[0]; const localExtension = this.extensionsWorkbenchService.local.filter(e => areSameExtensions(e.identifier, this.extension.identifier))[0];

View file

@ -338,11 +338,20 @@ export class ExtensionsListView extends ViewletPanel {
const isE1Running = running1 && this.extensionManagementServerService.getExtensionManagementServer(running1.extensionLocation) === e1.server; const isE1Running = running1 && this.extensionManagementServerService.getExtensionManagementServer(running1.extensionLocation) === e1.server;
const running2 = runningExtensionsById.get(ExtensionIdentifier.toKey(e2.identifier.id)); const running2 = runningExtensionsById.get(ExtensionIdentifier.toKey(e2.identifier.id));
const isE2Running = running2 && this.extensionManagementServerService.getExtensionManagementServer(running2.extensionLocation) === e2.server; const isE2Running = running2 && this.extensionManagementServerService.getExtensionManagementServer(running2.extensionLocation) === e2.server;
if ((isE1Running && isE2Running) || (!isE1Running && !isE2Running)) { if ((isE1Running && isE2Running)) {
return e1.displayName.localeCompare(e2.displayName); return e1.displayName.localeCompare(e2.displayName);
} }
const isE1LanguagePackExtension = e1.local && isLanguagePackExtension(e1.local.manifest); const isE1LanguagePackExtension = e1.local && isLanguagePackExtension(e1.local.manifest);
const isE2LanguagePackExtension = e2.local && isLanguagePackExtension(e2.local.manifest); const isE2LanguagePackExtension = e2.local && isLanguagePackExtension(e2.local.manifest);
if (!isE1Running && !isE2Running) {
if (isE1LanguagePackExtension) {
return -1;
}
if (isE2LanguagePackExtension) {
return 1;
}
return e1.displayName.localeCompare(e2.displayName);
}
if ((isE1Running && isE2LanguagePackExtension) || (isE2Running && isE1LanguagePackExtension)) { if ((isE1Running && isE2LanguagePackExtension) || (isE2Running && isE1LanguagePackExtension)) {
return e1.displayName.localeCompare(e2.displayName); return e1.displayName.localeCompare(e2.displayName);
} }

View file

@ -34,7 +34,7 @@ import * as resources from 'vs/base/common/resources';
import { CancellationToken } from 'vs/base/common/cancellation'; import { CancellationToken } from 'vs/base/common/cancellation';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IFileService } from 'vs/platform/files/common/files'; import { IFileService } from 'vs/platform/files/common/files';
import { IExtensionManifest, ExtensionType, ExtensionIdentifierWithVersion, IExtension as IPlatformExtension } from 'vs/platform/extensions/common/extensions'; import { IExtensionManifest, ExtensionType, ExtensionIdentifierWithVersion, IExtension as IPlatformExtension, isLanguagePackExtension } from 'vs/platform/extensions/common/extensions';
interface IExtensionStateProvider<T> { interface IExtensionStateProvider<T> {
(extension: Extension): T; (extension: Extension): T;
@ -584,15 +584,19 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
} }
get local(): IExtension[] { get local(): IExtension[] {
const result = [...this.localExtensions.local]; const result = [...this.installed];
if (!this.remoteExtensions) {
return result;
}
result.push(...this.remoteExtensions.local);
const byId = groupByExtension(result, r => r.identifier); const byId = groupByExtension(result, r => r.identifier);
return byId.reduce((result, extensions) => { result.push(this.getPrimaryExtension(extensions)); return result; }, []); return byId.reduce((result, extensions) => { result.push(this.getPrimaryExtension(extensions)); return result; }, []);
} }
get installed(): IExtension[] {
const result = [...this.localExtensions.local];
if (this.remoteExtensions) {
result.push(...this.remoteExtensions.local);
}
return result;
}
get outdated(): IExtension[] { get outdated(): IExtension[] {
const allLocal = [...this.localExtensions.local]; const allLocal = [...this.localExtensions.local];
if (this.remoteExtensions) { if (this.remoteExtensions) {
@ -812,7 +816,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
} }
return this.installWithProgress(async () => { return this.installWithProgress(async () => {
const extensionService = extension.server ? extension.server.extensionManagementService : this.extensionService; const extensionService = extension.server && extension.local && !isLanguagePackExtension(extension.local.manifest) ? extension.server.extensionManagementService : this.extensionService;
await extensionService.installFromGallery(gallery); await extensionService.installFromGallery(gallery);
this.checkAndEnableDisabledDependencies(gallery.identifier); this.checkAndEnableDisabledDependencies(gallery.identifier);
return this.local.filter(local => areSameExtensions(local.identifier, gallery.identifier))[0]; return this.local.filter(local => areSameExtensions(local.identifier, gallery.identifier))[0];
@ -855,7 +859,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
return Promise.reject(new Error(nls.localize('incompatible', "Unable to install extension '{0}' with version '{1}' as it is not compatible with VS Code.", extension.gallery!.identifier.id, version))); return Promise.reject(new Error(nls.localize('incompatible', "Unable to install extension '{0}' with version '{1}' as it is not compatible with VS Code.", extension.gallery!.identifier.id, version)));
} }
return this.installWithProgress(async () => { return this.installWithProgress(async () => {
const extensionService = extension.server ? extension.server.extensionManagementService : this.extensionService; const extensionService = extension.server && extension.local && !isLanguagePackExtension(extension.local.manifest) ? extension.server.extensionManagementService : this.extensionService;
await extensionService.installFromGallery(gallery); await extensionService.installFromGallery(gallery);
if (extension.latestVersion !== version) { if (extension.latestVersion !== version) {
this.ignoreAutoUpdate(new ExtensionIdentifierWithVersion(gallery.identifier, version)); this.ignoreAutoUpdate(new ExtensionIdentifierWithVersion(gallery.identifier, version));