diff --git a/src/vs/workbench/services/themes/browser/fileIconThemeStore.ts b/src/vs/workbench/services/themes/browser/fileIconThemeStore.ts index 0afad15ee6c..213986a9839 100644 --- a/src/vs/workbench/services/themes/browser/fileIconThemeStore.ts +++ b/src/vs/workbench/services/themes/browser/fileIconThemeStore.ts @@ -74,9 +74,10 @@ export class FileIconThemeStore extends Disposable { extensionId: ext.description.identifier.value, extensionPublisher: ext.description.publisher, extensionName: ext.description.name, - extensionIsBuiltin: ext.description.isBuiltin + extensionIsBuiltin: ext.description.isBuiltin, + extensionLocation: ext.description.extensionLocation }; - this.onIconThemes(ext.description.extensionLocation, extensionData, ext.value, ext.collector); + this.onIconThemes(extensionData, ext.value, ext.collector); } for (const theme of this.knownIconThemes) { if (!previousIds[theme.id]) { @@ -87,7 +88,7 @@ export class FileIconThemeStore extends Disposable { }); } - private onIconThemes(extensionLocation: URI, extensionData: ExtensionData, iconThemes: IThemeExtensionPoint[], collector: ExtensionMessageCollector): void { + private onIconThemes(extensionData: ExtensionData, iconThemes: IThemeExtensionPoint[], collector: ExtensionMessageCollector): void { if (!Array.isArray(iconThemes)) { collector.error(nls.localize( 'reqarray', @@ -116,9 +117,9 @@ export class FileIconThemeStore extends Disposable { return; } - const iconThemeLocation = resources.joinPath(extensionLocation, iconTheme.path); - if (!resources.isEqualOrParent(iconThemeLocation, extensionLocation)) { - collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", iconThemeExtPoint.name, iconThemeLocation.path, extensionLocation.path)); + const iconThemeLocation = resources.joinPath(extensionData.extensionLocation, iconTheme.path); + if (!resources.isEqualOrParent(iconThemeLocation, extensionData.extensionLocation)) { + collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", iconThemeExtPoint.name, iconThemeLocation.path, extensionData.extensionLocation.path)); } let themeData = FileIconThemeData.fromExtensionTheme(iconTheme, iconThemeLocation, extensionData); @@ -145,10 +146,10 @@ export class FileIconThemeStore extends Disposable { }); } - public findThemeDataByParentLocation(parentLocation: URI | undefined): Promise { - if (parentLocation) { + public findThemeDataByExtensionLocation(extLocation: URI | undefined): Promise { + if (extLocation) { return this.getFileIconThemes().then(allThemes => { - return allThemes.filter(t => t.location && resources.isEqualOrParent(t.location, parentLocation)); + return allThemes.filter(t => t.extensionData && resources.isEqualOrParent(t.extensionData.extensionLocation, extLocation)); }); } return Promise.resolve([]); diff --git a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts index a3b675c68cc..c2d10bf8442 100644 --- a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts @@ -285,8 +285,8 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { const extDevLocs = this.environmentService.extensionDevelopmentLocationURI; const initializeColorTheme = async () => { - if (extDevLocs && extDevLocs.length > 0) { // in dev mode, switch to a theme provided by the extension under dev. - const devThemes = await this.colorThemeStore.findThemeDataByParentLocation(extDevLocs[0]); + if (extDevLocs && extDevLocs.length === 1) { // in dev mode, switch to a theme provided by the extension under dev. + const devThemes = await this.colorThemeStore.findThemeDataByExtensionLocation(extDevLocs[0]); if (devThemes.length) { return this.setColorTheme(devThemes[0].id, ConfigurationTarget.MEMORY); } @@ -302,8 +302,8 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { }; const initializeIconTheme = async () => { - if (extDevLocs && extDevLocs.length > 0) { // in dev mode, switch to a theme provided by the extension under dev. - const devThemes = await this.iconThemeStore.findThemeDataByParentLocation(extDevLocs[0]); + if (extDevLocs && extDevLocs.length === 1) { // in dev mode, switch to a theme provided by the extension under dev. + const devThemes = await this.iconThemeStore.findThemeDataByExtensionLocation(extDevLocs[0]); if (devThemes.length) { return this.setFileIconTheme(devThemes[0].id, ConfigurationTarget.MEMORY); } diff --git a/src/vs/workbench/services/themes/common/colorThemeStore.ts b/src/vs/workbench/services/themes/common/colorThemeStore.ts index 7253ada3afd..32dc2ad1d2f 100644 --- a/src/vs/workbench/services/themes/common/colorThemeStore.ts +++ b/src/vs/workbench/services/themes/common/colorThemeStore.ts @@ -71,13 +71,14 @@ export class ColorThemeStore { } this.extensionsColorThemes.length = 0; for (let ext of extensions) { - let extensionData = { + let extensionData: ExtensionData = { extensionId: ext.description.identifier.value, extensionPublisher: ext.description.publisher, extensionName: ext.description.name, - extensionIsBuiltin: ext.description.isBuiltin + extensionIsBuiltin: ext.description.isBuiltin, + extensionLocation: ext.description.extensionLocation }; - this.onThemes(ext.description.extensionLocation, extensionData, ext.value, ext.collector); + this.onThemes(extensionData, ext.value, ext.collector); } for (const theme of this.extensionsColorThemes) { if (!previousIds[theme.id]) { @@ -88,7 +89,7 @@ export class ColorThemeStore { }); } - private onThemes(extensionLocation: URI, extensionData: ExtensionData, themes: IThemeExtensionPoint[], collector: ExtensionMessageCollector): void { + private onThemes(extensionData: ExtensionData, themes: IThemeExtensionPoint[], collector: ExtensionMessageCollector): void { if (!Array.isArray(themes)) { collector.error(nls.localize( 'reqarray', @@ -108,9 +109,9 @@ export class ColorThemeStore { return; } - const colorThemeLocation = resources.joinPath(extensionLocation, theme.path); - if (!resources.isEqualOrParent(colorThemeLocation, extensionLocation)) { - collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", themesExtPoint.name, colorThemeLocation.path, extensionLocation.path)); + const colorThemeLocation = resources.joinPath(extensionData.extensionLocation, theme.path); + if (!resources.isEqualOrParent(colorThemeLocation, extensionData.extensionLocation)) { + collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", themesExtPoint.name, colorThemeLocation.path, extensionData.extensionLocation.path)); } let themeData = ColorThemeData.fromExtensionTheme(theme, colorThemeLocation, extensionData); @@ -148,10 +149,10 @@ export class ColorThemeStore { }); } - public findThemeDataByParentLocation(parentLocation: URI | undefined): Promise { - if (parentLocation) { + public findThemeDataByExtensionLocation(extLocation: URI | undefined): Promise { + if (extLocation) { return this.getColorThemes().then(allThemes => { - return allThemes.filter(t => t.location && resources.isEqualOrParent(t.location, parentLocation)); + return allThemes.filter(t => t.extensionData && resources.isEqual(t.extensionData.extensionLocation, extLocation)); }); } return Promise.resolve([]); diff --git a/src/vs/workbench/services/themes/common/workbenchThemeService.ts b/src/vs/workbench/services/themes/common/workbenchThemeService.ts index 4756204b595..16765a13851 100644 --- a/src/vs/workbench/services/themes/common/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/common/workbenchThemeService.ts @@ -8,6 +8,7 @@ import { Event } from 'vs/base/common/event'; import { Color } from 'vs/base/common/color'; import { ITheme, IThemeService, IIconTheme } from 'vs/platform/theme/common/themeService'; import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; +import { URI } from 'vs/base/common/uri'; export const IWorkbenchThemeService = createDecorator('themeService'); @@ -101,6 +102,7 @@ export interface ExtensionData { extensionPublisher: string; extensionName: string; extensionIsBuiltin: boolean; + extensionLocation: URI; } export interface IThemeExtensionPoint {