Probably a better approach to check for values before assigning lest we replace something.

This commit is contained in:
Seivan Heidari 2019-11-10 22:30:53 +01:00
parent 83a33fbbea
commit 3886164bcc

View File

@ -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);
}