Skip to content

Commit 4731a22

Browse files
committed
Add a temporary implementation for semantic tokens styling (for microsoft/monaco-editor#1833)
1 parent d0c2483 commit 4731a22

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as dom from 'vs/base/browser/dom';
77
import { Color } from 'vs/base/common/color';
88
import { Emitter } from 'vs/base/common/event';
9-
import { TokenizationRegistry } from 'vs/editor/common/modes';
9+
import { FontStyle, TokenizationRegistry, TokenMetadata } from 'vs/editor/common/modes';
1010
import { ITokenThemeRule, TokenTheme, generateTokensCSSForColorMap } from 'vs/editor/common/modes/supports/tokenization';
1111
import { BuiltinTheme, IStandaloneTheme, IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
1212
import { hc_black, vs, vs_dark } from 'vs/editor/standalone/common/themes';
@@ -137,7 +137,17 @@ class StandaloneTheme implements IStandaloneTheme {
137137
}
138138

139139
public getTokenStyleMetadata(type: string, modifiers: string[], modelLanguage: string): ITokenStyle | undefined {
140-
return undefined;
140+
// use theme rules match
141+
const style = this.tokenTheme._match([type].concat(modifiers).join('.'));
142+
const metadata = style.metadata;
143+
const foreground = TokenMetadata.getForeground(metadata);
144+
const fontStyle = TokenMetadata.getFontStyle(metadata);
145+
return {
146+
foreground: foreground,
147+
italic: Boolean(fontStyle & FontStyle.Italic),
148+
bold: Boolean(fontStyle & FontStyle.Bold),
149+
underline: Boolean(fontStyle & FontStyle.Underline)
150+
};
141151
}
142152

143153
public get tokenColorMap(): string[] {

0 commit comments

Comments
 (0)