Skip to content

Commit 43ff1cf

Browse files
authored
fix(monaco): add missing theme fontStyle and background (#849)
Co-authored-by: lejunyang <[email protected]>
1 parent 76cbc7e commit 43ff1cf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/monaco/src/index.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { StateStack } from '@shikijs/vscode-textmate'
33
import type monacoNs from 'monaco-editor-core'
44
import { EncodedTokenMetadata, INITIAL } from '@shikijs/vscode-textmate'
55

6-
export interface MonacoTheme extends monacoNs.editor.IStandaloneThemeData {}
6+
export interface MonacoTheme extends monacoNs.editor.IStandaloneThemeData { }
77

88
export interface ShikiToMonacoOptions {
99
/**
@@ -28,13 +28,15 @@ export function textmateThemeToMonacoTheme(theme: ThemeRegistrationResolved): Mo
2828
if (!rules) {
2929
rules = []
3030
const themeSettings = theme.settings || theme.tokenColors
31-
for (const { scope, settings } of themeSettings) {
31+
for (const { scope, settings: { foreground, background, fontStyle } } of themeSettings) {
3232
const scopes = Array.isArray(scope) ? scope : [scope]
3333
for (const s of scopes) {
34-
if (settings.foreground && s) {
34+
if (s && (foreground || background || fontStyle)) {
3535
rules.push({
3636
token: s,
37-
foreground: normalizeColor(settings.foreground),
37+
foreground: normalizeColor(foreground),
38+
background: normalizeColor(background),
39+
fontStyle,
3840
})
3941
}
4042
}
@@ -148,7 +150,7 @@ export function shikiToMonaco(
148150
class TokenizerState implements monacoNs.languages.IState {
149151
constructor(
150152
private _ruleStack: StateStack,
151-
) {}
153+
) { }
152154

153155
public get ruleStack(): StateStack {
154156
return this._ruleStack

0 commit comments

Comments
 (0)