Skip to content

Commit

Permalink
#19685 Revert changes in Extension Description
Browse files Browse the repository at this point in the history
- Revert changes to id in Ext description. No lowering of name.
- Implement an equal function to check equality of extensions
- Use above function to check the equality with extension description
  • Loading branch information
sandy081 committed Mar 3, 2017
1 parent 77d7e0b commit 622b800
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

import { ILocalExtension, IGalleryExtension, IExtensionManifest, EXTENSION_IDENTIFIER_REGEX } from 'vs/platform/extensionManagement/common/extensionManagement';

export function areSameExtensions(a: { id: string }, b: { id: string }): boolean {
if (a.id === b.id) {
return true;
}
return adoptToGalleryExtensionId(a.id) === adoptToGalleryExtensionId(b.id);
}

export function getGalleryExtensionId(publisher: string, name: string): string {
return `${publisher}.${name.toLocaleLowerCase()}`;
}
Expand Down
2 changes: 0 additions & 2 deletions src/vs/platform/extensions/common/abstractExtensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
import { IExtensionDescription, IExtensionService, IExtensionsStatus, ExtensionPointContribution } from 'vs/platform/extensions/common/extensions';
import { IExtensionPoint } from 'vs/platform/extensions/common/extensionsRegistry';
import { adoptToGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';

const hasOwnProperty = Object.hasOwnProperty;

Expand Down Expand Up @@ -293,7 +292,6 @@ export class ExtensionDescriptionRegistry {
}

public getExtensionDescription(extensionId: string): IExtensionDescription {
extensionId = adoptToGalleryExtensionId(extensionId);
if (!hasOwnProperty.call(this._extensionsMap, extensionId)) {
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/api/node/mainThreadExtensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import URI from 'vs/base/common/uri';
import { AbstractExtensionService, ActivatedExtension } from 'vs/platform/extensions/common/abstractExtensionService';
import { IMessage, IExtensionDescription, IExtensionsStatus } from 'vs/platform/extensions/common/extensions';
import { IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ExtensionsRegistry, ExtensionPoint, IExtensionPointUser, ExtensionMessageCollector } from 'vs/platform/extensions/common/extensionsRegistry';
import { ExtensionScanner, MessagesCollector } from 'vs/workbench/node/extensionPoints';
import { IMessageService } from 'vs/platform/message/common/message';
Expand Down Expand Up @@ -81,7 +82,7 @@ export class MainProcessExtensionService extends AbstractExtensionService<Activa
];

this.scanExtensions().done(extensionDescriptions => {
this._onExtensionDescriptions(disabledExtensions.length ? extensionDescriptions.filter(e => disabledExtensions.indexOf(e.id) === -1) : extensionDescriptions);
this._onExtensionDescriptions(disabledExtensions.length ? extensionDescriptions.filter(e => disabledExtensions.every(id => !areSameExtensions({ id }, e))) : extensionDescriptions);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/node/extensionPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import json = require('vs/base/common/json');
import Types = require('vs/base/common/types');
import { isValidExtensionDescription } from 'vs/platform/extensions/node/extensionValidator';
import * as semver from 'semver';
import { getIdAndVersionFromLocalExtensionId, getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { getIdAndVersionFromLocalExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';

const MANIFEST_FILE = 'package.json';

Expand Down Expand Up @@ -237,7 +237,7 @@ class ExtensionManifestValidator extends ExtensionManifestHandler {
});

// id := `publisher.name`
extensionDescription.id = getGalleryExtensionId(extensionDescription.publisher, extensionDescription.name);
extensionDescription.id = `${extensionDescription.publisher}.${extensionDescription.name}`;

// main := absolutePath(`main`)
if (extensionDescription.main) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IExtension, ExtensionState, IExtensionsWorkbenchService, VIEWLET_ID, IExtensionsViewlet } from 'vs/workbench/parts/extensions/common/extensions';
import { ExtensionsConfigurationInitialContent } from 'vs/workbench/parts/extensions/common/extensionsFileTemplate';
import { LocalExtensionType, IExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService } from 'vs/platform/message/common/message';
import { ToggleViewletAction } from 'vs/workbench/browser/viewlet';
Expand Down Expand Up @@ -765,7 +766,7 @@ export class ReloadAction extends Action {
const isUninstalled = this.extension.state === ExtensionState.Uninstalled;
const isDisabled = this.extension.disabledForWorkspace || this.extension.disabledGlobally;

const filteredExtensions = runningExtensions.filter(e => e.id === this.extension.id);
const filteredExtensions = runningExtensions.filter(e => areSameExtensions(e, this.extension));
const isExtensionRunning = filteredExtensions.length > 0;
const isDifferentVersionRunning = filteredExtensions.length > 0 && this.extension.version !== filteredExtensions[0].version;

Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/parts/extensions/browser/extensionsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { once } from 'vs/base/common/event';
import { domEvent } from 'vs/base/browser/event';
import { IExtension, IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions';
import { InstallAction, UpdateAction, BuiltinStatusLabelAction, ManageExtensionAction, ReloadAction } from 'vs/workbench/parts/extensions/browser/extensionsActions';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { Label, RatingsWidget, InstallWidget } from 'vs/workbench/parts/extensions/browser/extensionsWidgets';
import { EventType } from 'vs/base/common/events';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
Expand Down Expand Up @@ -128,7 +129,7 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
data.extensionDisposables = dispose(data.extensionDisposables);

this.extensionService.getExtensions().then(enabledExtensions => {
const isExtensionRunning = enabledExtensions.some(e => e.id === extension.id);
const isExtensionRunning = enabledExtensions.some(e => areSameExtensions(e, extension));
const isInstalled = this.extensionsWorkbenchService.local.some(e => e.id === extension.id);
toggleClass(data.element, 'disabled', isInstalled && !isExtensionRunning);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
} from 'vs/workbench/parts/extensions/browser/extensionsActions';
import { InstallVSIXAction } from 'vs/workbench/parts/extensions/electron-browser/extensionsActions';
import { IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, SortBy, SortOrder, IQueryOptions, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
import { Query } from '../common/extensionQuery';
import { OpenGlobalSettingsAction } from 'vs/workbench/parts/preferences/browser/preferencesActions';
Expand Down Expand Up @@ -259,7 +260,7 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
return this.extensionsWorkbenchService.queryLocal()
.then(result => result.sort((e1, e2) => e1.displayName.localeCompare(e2.displayName)))
.then(result => this.extensionService.getExtensions()
.then(runningExtensions => result.filter(e => runningExtensions.every(r => r.id !== e.id) && e.name.toLowerCase().indexOf(value) > -1)))
.then(runningExtensions => result.filter(e => runningExtensions.every(r => !areSameExtensions(r, e)) && e.name.toLowerCase().indexOf(value) > -1)))
.then(result => new PagedModel(result));
}

Expand Down

0 comments on commit 622b800

Please sign in to comment.