From 3886164bcce734825d20a1af08ce359fbe0710e3 Mon Sep 17 00:00:00 2001 From: Seivan Heidari Date: Sun, 10 Nov 2019 22:30:53 +0100 Subject: Probably a better approach to check for values before assigning lest we replace something. --- editors/code/src/highlighting.ts | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 14199dbea..0a38c9ef6 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts @@ -30,9 +30,33 @@ function createDecorationFromTextmate( ): vscode.TextEditorDecorationType { const decorationOptions: vscode.DecorationRenderOptions = {}; decorationOptions.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen; - decorationOptions.color = themeStyle.foreground; - decorationOptions.backgroundColor = themeStyle.background; - decorationOptions.fontStyle = themeStyle.fontStyle; + + if (themeStyle.foreground) { + decorationOptions.color = themeStyle.foreground; + } + + if (themeStyle.background) { + decorationOptions.backgroundColor = themeStyle.background; + } + + if (themeStyle.fontStyle) { + const parts: string[] = themeStyle.fontStyle.split(' '); + parts.forEach(part => { + switch (part) { + case 'italic': + decorationOptions.fontStyle = 'italic'; + break; + case 'bold': + decorationOptions.fontWeight = 'bold'; + break; + case 'underline': + decorationOptions.textDecoration = 'underline'; + break; + default: + break; + } + }); + } return vscode.window.createTextEditorDecorationType(decorationOptions); } -- cgit v1.2.3