fixes for theming semantic tokens

pull/85384/head
Martin Aeschlimann 2019-11-22 13:52:24 +01:00
parent a78363abd0
commit 1803c7fd76
4 changed files with 14 additions and 9 deletions

View File

@ -34,16 +34,16 @@ export function activate(context: vscode.ExtensionContext): any {
result.push(startCharacter + length);
const segments = property.split('.');
let tokenType = legend.tokenTypes.indexOf(segments[0]);
const [type, ...modifiers] = property.split('.');
let tokenType = legend.tokenTypes.indexOf(type);
if (tokenType === -1) {
tokenType = 0;
}
result.push(tokenType);
let tokenModifiers = 0;
for (let i = 1; i < segments.length; i++) {
const index = legend.tokenTypes.indexOf(segments[0]);
for (let i = 0; i < modifiers.length; i++) {
const index = legend.tokenModifiers.indexOf(modifiers[i]);
if (index !== -1) {
tokenModifiers = tokenModifiers | 1 << index;
}

View File

@ -476,6 +476,7 @@ class ModelSemanticColoring extends Disposable {
this._register(this._model.onDidChangeContent(e => this._fetchSemanticTokens.schedule()));
this._register(SemanticColoringProviderRegistry.onDidChange(e => this._fetchSemanticTokens.schedule()));
this._register(themeService.onThemeChange(_ => this._fetchSemanticTokens.schedule()));
this._fetchSemanticTokens.schedule(0);
}
@ -554,12 +555,13 @@ class ModelSemanticColoring extends Disposable {
const tokenTypeIndex = srcTokens[srcOffset + 3];
const tokenType = legend.tokenTypes[tokenTypeIndex];
const tokenModifierSet = srcTokens[srcOffset + 4];
let tokenModifierSet = srcTokens[srcOffset + 4];
let tokenModifiers: string[] = [];
for (let modifierIndex = 0; tokenModifierSet !== 0 && modifierIndex < legend.tokenModifiers.length; modifierIndex++) {
if (tokenModifierSet & 1) {
tokenModifiers.push(legend.tokenTypes[modifierIndex]);
tokenModifiers.push(legend.tokenModifiers[modifierIndex]);
}
tokenModifierSet = tokenModifierSet >> 1;
}
const metadata = this._themeService.getTheme().getTokenStyleMetadata(tokenType, tokenModifiers);

View File

@ -364,10 +364,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
this.currentColorTheme = themeData;
themeData.setCustomColors(this.colorCustomizations);
themeData.setCustomTokenColors(this.tokenColorCustomizations);
themeData.setCustomTokenStyleRules(this.tokenStylesCustomizations);
return Promise.resolve(themeData);
}
themeData.setCustomColors(this.colorCustomizations);
themeData.setCustomTokenColors(this.tokenColorCustomizations);
themeData.setCustomTokenStyleRules(this.tokenStylesCustomizations);
this.updateDynamicCSSRules(themeData);
return this.applyTheme(themeData, settingsTarget);
}, error => {
@ -380,6 +382,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
await this.currentColorTheme.reload(this.extensionResourceLoaderService);
this.currentColorTheme.setCustomColors(this.colorCustomizations);
this.currentColorTheme.setCustomTokenColors(this.tokenColorCustomizations);
this.currentColorTheme.setCustomTokenStyleRules(this.tokenStylesCustomizations);
this.updateDynamicCSSRules(this.currentColorTheme);
this.applyTheme(this.currentColorTheme, undefined, false);
}

View File

@ -340,12 +340,12 @@ export class ColorThemeData implements IColorTheme {
}
public setCustomTokenStyleRules(tokenStylingRules: IExperimentalTokenStyleCustomizations) {
this.tokenStylingRules = [];
readCustomTokenStyleRules(tokenStylingRules, this.tokenStylingRules);
this.customTokenStylingRules = [];
readCustomTokenStyleRules(tokenStylingRules, this.customTokenStylingRules);
const themeSpecificColors = tokenStylingRules[`[${this.settingsId}]`] as IExperimentalTokenStyleCustomizations;
if (types.isObject(themeSpecificColors)) {
readCustomTokenStyleRules(themeSpecificColors, this.tokenStylingRules);
readCustomTokenStyleRules(themeSpecificColors, this.customTokenStylingRules);
}
this.tokenColorIndex = undefined;