提交 1a7d482b 编写于 作者: M Martin Aeschlimann

[themes] check if persisted theme matches the loaded theme

上级 7749f542
......@@ -12,6 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { getBaseThemeId, getSyntaxThemeId, isDarkTheme, isLightTheme } from 'vs/platform/theme/common/themes';
import nls = require('vs/nls');
import * as types from 'vs/base/common/types';
import * as objects from 'vs/base/common/objects';
import * as plist from 'fast-plist';
import pfs = require('vs/base/node/pfs');
......@@ -99,12 +100,15 @@ export class ColorThemeData implements IColorTheme {
settingsId: this.settingsId,
selector: this.selector,
tokenColors: this.tokenColors,
isLoaded: true,
extensionData: this.extensionData,
colorMap: colorMapData
});
}
hasEqualData(other: ColorThemeData) {
return objects.equals(this.colorMap, other.colorMap) && objects.equals(this.tokenColors, other.tokenColors);
}
get type(): ThemeType {
switch (this.getBaseThemeId()) {
case VS_LIGHT_THEME: return 'light';
......
......@@ -181,7 +181,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
_serviceBrand: any;
private knownColorThemes: ColorThemeData[];
private currentColorTheme: IColorTheme;
private currentColorTheme: ColorThemeData;
private container: HTMLElement;
private onColorThemeChange: Emitter<IColorTheme>;
......@@ -392,6 +392,11 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return this.findThemeData(themeId, DEFAULT_THEME_ID).then(themeData => {
if (themeData) {
return themeData.ensureLoaded().then(_ => {
if (themeId === this.currentColorTheme.id && !this.currentColorTheme.isLoaded && this.currentColorTheme.hasEqualData(themeData)) {
// the loaded theme is identical to the perisisted theme. Don't need to send an event.
this.currentColorTheme = themeData;
return TPromise.as(themeData);
}
this.updateDynamicCSSRules(themeData);
return this.applyTheme(themeData, settingsTarget);
}, error => {
......@@ -427,12 +432,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
this.currentColorTheme = newTheme;
this.themingParticipantChangeListener = themingRegistry.onThemingParticipantAdded(p => this.updateDynamicCSSRules(this.currentColorTheme));
this.sendTelemetry(newTheme.id, newTheme.extensionData, 'color');
if (silent) {
return TPromise.as(null);
}
this.sendTelemetry(newTheme.id, newTheme.extensionData, 'color');
this.onColorThemeChange.fire(this.currentColorTheme);
if (settingsTarget !== ConfigurationTarget.WORKSPACE) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册