diff options
author | Seivan Heidari <[email protected]> | 2019-12-23 23:04:36 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-12-23 23:04:36 +0000 |
commit | 25537d294cb7a3e01d2329a7d07b469d734fc829 (patch) | |
tree | 6d08e6c48ddf4bf8a3168daee0d0d31c137b8785 /editors/code/src | |
parent | b21d9337d9200e2cfdc90b386591c72c302dc03e (diff) |
Fix https://github.com/rust-analyzer/rust-analyzer/pull/2061#discussion_r348716036
Fix https://github.com/rust-analyzer/rust-analyzer/pull/2061/files/68a5ff050faf514e9d122212a66703ca8ce66ab7#r361019340
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/highlighting.ts | 4 | ||||
-rw-r--r-- | editors/code/src/scopes.ts | 10 | ||||
-rw-r--r-- | editors/code/src/scopes_mapper.ts | 17 |
3 files changed, 15 insertions, 16 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 68eae0941..4e224a54c 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -26,7 +26,7 @@ function fancify(seed: string, shade: 'light' | 'dark') { | |||
26 | } | 26 | } |
27 | 27 | ||
28 | function createDecorationFromTextmate( | 28 | function createDecorationFromTextmate( |
29 | themeStyle: scopes.TextMateRuleSettings | 29 | themeStyle: scopes.TextMateRuleSettings, |
30 | ): vscode.TextEditorDecorationType { | 30 | ): vscode.TextEditorDecorationType { |
31 | const decorationOptions: vscode.DecorationRenderOptions = {}; | 31 | const decorationOptions: vscode.DecorationRenderOptions = {}; |
32 | decorationOptions.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen; | 32 | decorationOptions.rangeBehavior = vscode.DecorationRangeBehavior.OpenOpen; |
@@ -84,7 +84,7 @@ export class Highlighter { | |||
84 | const color = new vscode.ThemeColor(fallBackTag); | 84 | const color = new vscode.ThemeColor(fallBackTag); |
85 | const decor = vscode.window.createTextEditorDecorationType({ | 85 | const decor = vscode.window.createTextEditorDecorationType({ |
86 | color, | 86 | color, |
87 | textDecoration | 87 | textDecoration, |
88 | }); | 88 | }); |
89 | return [tag, decor]; | 89 | return [tag, decor]; |
90 | } | 90 | } |
diff --git a/editors/code/src/scopes.ts b/editors/code/src/scopes.ts index 8f288d761..cb250b853 100644 --- a/editors/code/src/scopes.ts +++ b/editors/code/src/scopes.ts | |||
@@ -58,10 +58,10 @@ function loadThemeNamed(themeName: string) { | |||
58 | return extension.packageJSON.contributes.themes | 58 | return extension.packageJSON.contributes.themes |
59 | .filter( | 59 | .filter( |
60 | (element: any) => | 60 | (element: any) => |
61 | (element.id || element.label) === themeName | 61 | (element.id || element.label) === themeName, |
62 | ) | 62 | ) |
63 | .map((element: any) => | 63 | .map((element: any) => |
64 | path.join(extension.extensionPath, element.path) | 64 | path.join(extension.extensionPath, element.path), |
65 | ) | 65 | ) |
66 | .concat(list); | 66 | .concat(list); |
67 | }, Array<string>()); | 67 | }, Array<string>()); |
@@ -71,7 +71,7 @@ function loadThemeNamed(themeName: string) { | |||
71 | const tokenColorCustomizations: [any] = [ | 71 | const tokenColorCustomizations: [any] = [ |
72 | vscode.workspace | 72 | vscode.workspace |
73 | .getConfiguration('editor') | 73 | .getConfiguration('editor') |
74 | .get('tokenColorCustomizations') | 74 | .get('tokenColorCustomizations'), |
75 | ]; | 75 | ]; |
76 | 76 | ||
77 | tokenColorCustomizations | 77 | tokenColorCustomizations |
@@ -100,7 +100,7 @@ function loadThemeFile(themePath: string) { | |||
100 | 100 | ||
101 | function mergeRuleSettings( | 101 | function mergeRuleSettings( |
102 | defaultSetting: TextMateRuleSettings | undefined, | 102 | defaultSetting: TextMateRuleSettings | undefined, |
103 | override: TextMateRuleSettings | 103 | override: TextMateRuleSettings, |
104 | ): TextMateRuleSettings { | 104 | ): TextMateRuleSettings { |
105 | if (defaultSetting === undefined) { | 105 | if (defaultSetting === undefined) { |
106 | return override; | 106 | return override; |
@@ -116,7 +116,7 @@ function mergeRuleSettings( | |||
116 | 116 | ||
117 | function updateRules( | 117 | function updateRules( |
118 | scope: string, | 118 | scope: string, |
119 | updatedSettings: TextMateRuleSettings | 119 | updatedSettings: TextMateRuleSettings, |
120 | ): void { | 120 | ): void { |
121 | [rules.get(scope)] | 121 | [rules.get(scope)] |
122 | .map(settings => mergeRuleSettings(settings, updatedSettings)) | 122 | .map(settings => mergeRuleSettings(settings, updatedSettings)) |
diff --git a/editors/code/src/scopes_mapper.ts b/editors/code/src/scopes_mapper.ts index 85c791ff5..e738fa239 100644 --- a/editors/code/src/scopes_mapper.ts +++ b/editors/code/src/scopes_mapper.ts | |||
@@ -10,15 +10,15 @@ const defaultMapping = new Map<string, string[]>([ | |||
10 | 'comment', | 10 | 'comment', |
11 | 'comment.block', | 11 | 'comment.block', |
12 | 'comment.line', | 12 | 'comment.line', |
13 | 'comment.block.documentation' | 13 | 'comment.block.documentation', |
14 | ] | 14 | ], |
15 | ], | 15 | ], |
16 | ['string', ['string']], | 16 | ['string', ['string']], |
17 | ['keyword', ['keyword']], | 17 | ['keyword', ['keyword']], |
18 | ['keyword.control', ['keyword.control', 'keyword', 'keyword.other']], | 18 | ['keyword.control', ['keyword.control', 'keyword', 'keyword.other']], |
19 | [ | 19 | [ |
20 | 'keyword.unsafe', | 20 | 'keyword.unsafe', |
21 | ['storage.modifier', 'keyword.other', 'keyword.control', 'keyword'] | 21 | ['storage.modifier', 'keyword.other', 'keyword.control', 'keyword'], |
22 | ], | 22 | ], |
23 | ['function', ['entity.name.function']], | 23 | ['function', ['entity.name.function']], |
24 | ['parameter', ['variable.parameter']], | 24 | ['parameter', ['variable.parameter']], |
@@ -28,7 +28,7 @@ const defaultMapping = new Map<string, string[]>([ | |||
28 | ['text', ['string', 'string.quoted', 'string.regexp']], | 28 | ['text', ['string', 'string.quoted', 'string.regexp']], |
29 | ['attribute', ['keyword']], | 29 | ['attribute', ['keyword']], |
30 | ['literal', ['string', 'string.quoted', 'string.regexp']], | 30 | ['literal', ['string', 'string.quoted', 'string.regexp']], |
31 | ['macro', ['support.other']], | 31 | ['macro', ['entity.name.function', 'keyword.other', 'entity.name.macro']], |
32 | ['variable', ['variable']], | 32 | ['variable', ['variable']], |
33 | ['variable.mut', ['variable', 'storage.modifier']], | 33 | ['variable.mut', ['variable', 'storage.modifier']], |
34 | [ | 34 | [ |
@@ -37,20 +37,19 @@ const defaultMapping = new Map<string, string[]>([ | |||
37 | 'variable.object.property', | 37 | 'variable.object.property', |
38 | 'meta.field.declaration', | 38 | 'meta.field.declaration', |
39 | 'meta.definition.property', | 39 | 'meta.definition.property', |
40 | 'variable.other' | 40 | 'variable.other', |
41 | ] | 41 | ], |
42 | ], | 42 | ], |
43 | ['module', ['entity.name.section', 'entity.other']] | 43 | ['module', ['entity.name.section', 'entity.other']], |
44 | ]); | 44 | ]); |
45 | 45 | ||
46 | // Temporary exported for debugging for now. | ||
47 | export function find(scope: string): string[] { | 46 | export function find(scope: string): string[] { |
48 | return mappings.get(scope) || []; | 47 | return mappings.get(scope) || []; |
49 | } | 48 | } |
50 | 49 | ||
51 | export function toRule( | 50 | export function toRule( |
52 | scope: string, | 51 | scope: string, |
53 | intoRule: (scope: string) => TextMateRuleSettings | undefined | 52 | intoRule: (scope: string) => TextMateRuleSettings | undefined, |
54 | ): TextMateRuleSettings | undefined { | 53 | ): TextMateRuleSettings | undefined { |
55 | return find(scope) | 54 | return find(scope) |
56 | .map(intoRule) | 55 | .map(intoRule) |