aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/highlighting.ts
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-12-23 14:35:31 +0000
committerSeivan Heidari <[email protected]>2019-12-23 14:35:31 +0000
commitb21d9337d9200e2cfdc90b386591c72c302dc03e (patch)
treef81f5c08f821115cee26fa4d3ceaae88c7807fd5 /editors/code/src/highlighting.ts
parent18a0937585b836ec5ed054b9ae48e0156ab6d9ef (diff)
parentce07a2daa9e53aa86a769f8641b14c2878444fbc (diff)
Merge branch 'master' into feature/themes
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r--editors/code/src/highlighting.ts30
1 files changed, 18 insertions, 12 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 0a38c9ef6..68eae0941 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -67,7 +67,7 @@ export class Highlighter {
67 > { 67 > {
68 const decoration = ( 68 const decoration = (
69 tag: string, 69 tag: string,
70 textDecoration?: string 70 textDecoration?: string,
71 ): [string, vscode.TextEditorDecorationType] => { 71 ): [string, vscode.TextEditorDecorationType] => {
72 const rule = scopesMapper.toRule(tag, scopes.find); 72 const rule = scopesMapper.toRule(tag, scopes.find);
73 73
@@ -90,9 +90,10 @@ export class Highlighter {
90 } 90 }
91 }; 91 };
92 92
93 const decorations: Iterable< 93 const decorations: Iterable<[
94 [string, vscode.TextEditorDecorationType] 94 string,
95 > = [ 95 vscode.TextEditorDecorationType,
96 ]> = [
96 decoration('comment'), 97 decoration('comment'),
97 decoration('string'), 98 decoration('string'),
98 decoration('keyword'), 99 decoration('keyword'),
@@ -101,16 +102,23 @@ export class Highlighter {
101 decoration('function'), 102 decoration('function'),
102 decoration('parameter'), 103 decoration('parameter'),
103 decoration('constant'), 104 decoration('constant'),
105 decoration('type.builtin'),
106 decoration('type.generic'),
107 decoration('type.lifetime'),
108 decoration('type.param'),
109 decoration('type.self'),
104 decoration('type'), 110 decoration('type'),
105 decoration('builtin'),
106 decoration('text'), 111 decoration('text'),
107 decoration('attribute'), 112 decoration('attribute'),
108 decoration('literal'), 113 decoration('literal'),
114 decoration('literal.numeric'),
115 decoration('literal.char'),
116 decoration('literal.byte'),
109 decoration('macro'), 117 decoration('macro'),
110 decoration('variable'), 118 decoration('variable'),
111 decoration('variable.mut', 'underline'), 119 decoration('variable.mut', 'underline'),
112 decoration('field'), 120 decoration('field'),
113 decoration('module') 121 decoration('module'),
114 ]; 122 ];
115 123
116 return new Map<string, vscode.TextEditorDecorationType>(decorations); 124 return new Map<string, vscode.TextEditorDecorationType>(decorations);
@@ -139,7 +147,6 @@ export class Highlighter {
139 // 147 //
140 // Note: decoration objects need to be kept around so we can dispose them 148 // Note: decoration objects need to be kept around so we can dispose them
141 // if the user disables syntax highlighting 149 // if the user disables syntax highlighting
142
143 if (this.decorations == null) { 150 if (this.decorations == null) {
144 this.decorations = Highlighter.initDecorations(); 151 this.decorations = Highlighter.initDecorations();
145 } 152 }
@@ -168,23 +175,22 @@ export class Highlighter {
168 colorfulIdents 175 colorfulIdents
169 .get(d.bindingHash)![0] 176 .get(d.bindingHash)![0]
170 .push( 177 .push(
171 Server.client.protocol2CodeConverter.asRange(d.range) 178 Server.client.protocol2CodeConverter.asRange(d.range),
172 ); 179 );
173 } else { 180 } else {
174 byTag 181 byTag
175 .get(d.tag)! 182 .get(d.tag)!
176 .push( 183 .push(
177 Server.client.protocol2CodeConverter.asRange(d.range) 184 Server.client.protocol2CodeConverter.asRange(d.range),
178 ); 185 );
179 } 186 }
180 } 187 }
181 188
182 for (const tag of byTag.keys()) { 189 for (const tag of byTag.keys()) {
183 const dec = this.decorations.get( 190 const dec = this.decorations.get(
184 tag 191 tag,
185 ) as vscode.TextEditorDecorationType; 192 ) as vscode.TextEditorDecorationType;
186 const ranges = byTag.get(tag)!; 193 const ranges = byTag.get(tag)!;
187
188 editor.setDecorations(dec, ranges); 194 editor.setDecorations(dec, ranges);
189 } 195 }
190 196
@@ -192,7 +198,7 @@ export class Highlighter {
192 const textDecoration = mut ? 'underline' : undefined; 198 const textDecoration = mut ? 'underline' : undefined;
193 const dec = vscode.window.createTextEditorDecorationType({ 199 const dec = vscode.window.createTextEditorDecorationType({
194 light: { color: fancify(hash, 'light'), textDecoration }, 200 light: { color: fancify(hash, 'light'), textDecoration },
195 dark: { color: fancify(hash, 'dark'), textDecoration } 201 dark: { color: fancify(hash, 'dark'), textDecoration },
196 }); 202 });
197 editor.setDecorations(dec, ranges); 203 editor.setDecorations(dec, ranges);
198 } 204 }