Skip to content

Commit

Permalink
fix(monaco): add missing theme fontStyle and background (#849)
Browse files Browse the repository at this point in the history
Co-authored-by: lejunyang <[email protected]>
  • Loading branch information
lejunyang and lejunyang authored Nov 27, 2024
1 parent 76cbc7e commit 43ff1cf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/monaco/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { StateStack } from '@shikijs/vscode-textmate'
import type monacoNs from 'monaco-editor-core'
import { EncodedTokenMetadata, INITIAL } from '@shikijs/vscode-textmate'

export interface MonacoTheme extends monacoNs.editor.IStandaloneThemeData {}
export interface MonacoTheme extends monacoNs.editor.IStandaloneThemeData { }

export interface ShikiToMonacoOptions {
/**
Expand All @@ -28,13 +28,15 @@ export function textmateThemeToMonacoTheme(theme: ThemeRegistrationResolved): Mo
if (!rules) {
rules = []
const themeSettings = theme.settings || theme.tokenColors
for (const { scope, settings } of themeSettings) {
for (const { scope, settings: { foreground, background, fontStyle } } of themeSettings) {
const scopes = Array.isArray(scope) ? scope : [scope]
for (const s of scopes) {
if (settings.foreground && s) {
if (s && (foreground || background || fontStyle)) {
rules.push({
token: s,
foreground: normalizeColor(settings.foreground),
foreground: normalizeColor(foreground),
background: normalizeColor(background),
fontStyle,
})
}
}
Expand Down Expand Up @@ -148,7 +150,7 @@ export function shikiToMonaco(
class TokenizerState implements monacoNs.languages.IState {
constructor(
private _ruleStack: StateStack,
) {}
) { }

public get ruleStack(): StateStack {
return this._ruleStack
Expand Down

0 comments on commit 43ff1cf

Please sign in to comment.