mirror of
https://github.com/Microsoft/vscode
synced 2024-10-13 06:48:17 +00:00
[theme] only autoswitch theme with single ext under dev. Fixes #88169
This commit is contained in:
parent
18f94a526b
commit
58345c6709
|
@ -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<FileIconThemeData[]> {
|
||||
if (parentLocation) {
|
||||
public findThemeDataByExtensionLocation(extLocation: URI | undefined): Promise<FileIconThemeData[]> {
|
||||
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([]);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<ColorThemeData[]> {
|
||||
if (parentLocation) {
|
||||
public findThemeDataByExtensionLocation(extLocation: URI | undefined): Promise<ColorThemeData[]> {
|
||||
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([]);
|
||||
|
|
|
@ -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<IWorkbenchThemeService>('themeService');
|
||||
|
||||
|
@ -101,6 +102,7 @@ export interface ExtensionData {
|
|||
extensionPublisher: string;
|
||||
extensionName: string;
|
||||
extensionIsBuiltin: boolean;
|
||||
extensionLocation: URI;
|
||||
}
|
||||
|
||||
export interface IThemeExtensionPoint {
|
||||
|
|
Loading…
Reference in a new issue