From 83a33fbbeae9cbec8bec855e9338b7ccd08bd3a0 Mon Sep 17 00:00:00 2001 From: Seivan Heidari Date: Sat, 9 Nov 2019 17:23:30 +0100 Subject: Vscode wasn't running the linter automatically so ran `npm run fix` - wonder if it's related to `tslint` being deprecated. --- editors/code/src/highlighting.ts | 81 ++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 52 deletions(-) (limited to 'editors/code/src/highlighting.ts') diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index ee39ca64c..14199dbea 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts @@ -25,35 +25,15 @@ function fancify(seed: string, shade: 'light' | 'dark') { return `hsl(${h},${s}%,${l}%)`; } - -function createDecorationFromTextmate(themeStyle: scopes.TextMateRuleSettings): vscode.TextEditorDecorationType { - const options: vscode.DecorationRenderOptions = {}; - options.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen; - if (themeStyle.foreground) { - options.color = themeStyle.foreground; - } - if (themeStyle.background) { - options.backgroundColor = themeStyle.background; - } - if (themeStyle.fontStyle) { - const parts: string[] = themeStyle.fontStyle.split(' '); - parts.forEach((part) => { - switch (part) { - case 'italic': - options.fontStyle = 'italic'; - break; - case 'bold': - options.fontWeight = 'bold'; - break; - case 'underline': - options.textDecoration = 'underline'; - break; - default: - break; - } - }) - } - return vscode.window.createTextEditorDecorationType(options); +function createDecorationFromTextmate( + themeStyle: scopes.TextMateRuleSettings +): vscode.TextEditorDecorationType { + const decorationOptions: vscode.DecorationRenderOptions = {}; + decorationOptions.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen; + decorationOptions.color = themeStyle.foreground; + decorationOptions.backgroundColor = themeStyle.background; + decorationOptions.fontStyle = themeStyle.fontStyle; + return vscode.window.createTextEditorDecorationType(decorationOptions); } export class Highlighter { @@ -65,14 +45,12 @@ export class Highlighter { tag: string, textDecoration?: string ): [string, vscode.TextEditorDecorationType] => { - const rule = scopesMapper.toRule(tag, scopes.find); if (rule) { const decor = createDecorationFromTextmate(rule); return [tag, decor]; - } - else { + } else { const fallBackTag = 'ralsp.' + tag; // console.log(' '); // console.log('Missing theme for: <"' + tag + '"> for following mapped scopes:'); @@ -91,25 +69,25 @@ export class Highlighter { const decorations: Iterable< [string, vscode.TextEditorDecorationType] > = [ - decoration('comment'), - decoration('string'), - decoration('keyword'), - decoration('keyword.control'), - decoration('keyword.unsafe'), - decoration('function'), - decoration('parameter'), - decoration('constant'), - decoration('type'), - decoration('builtin'), - decoration('text'), - decoration('attribute'), - decoration('literal'), - decoration('macro'), - decoration('variable'), - decoration('variable.mut', 'underline'), - decoration('field'), - decoration('module') - ]; + decoration('comment'), + decoration('string'), + decoration('keyword'), + decoration('keyword.control'), + decoration('keyword.unsafe'), + decoration('function'), + decoration('parameter'), + decoration('constant'), + decoration('type'), + decoration('builtin'), + decoration('text'), + decoration('attribute'), + decoration('literal'), + decoration('macro'), + decoration('variable'), + decoration('variable.mut', 'underline'), + decoration('field'), + decoration('module') + ]; return new Map(decorations); } @@ -138,7 +116,6 @@ export class Highlighter { // Note: decoration objects need to be kept around so we can dispose them // if the user disables syntax highlighting - if (this.decorations == null) { this.decorations = Highlighter.initDecorations(); } -- cgit v1.2.3