aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-19 12:43:36 +0100
committerAleksey Kladov <[email protected]>2019-07-19 13:07:18 +0100
commite4188899962774713707629d4e15255e3bc9c85e (patch)
treed8628de91673d4d40b46ef62b994613f365f6b32 /editors/code/src
parentf209843e31af7f0e0212aa28ffec2efad2a70c6f (diff)
underline mutable bindings
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/highlighting.ts61
1 files changed, 34 insertions, 27 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index f3ed66365..d21d8a06a 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -28,12 +28,14 @@ export class Highlighter {
28 string, 28 string,
29 vscode.TextEditorDecorationType 29 vscode.TextEditorDecorationType
30 > { 30 > {
31 const colorContrib = ( 31 const decoration = (
32 tag: string 32 tag: string,
33 textDecoration?: string
33 ): [string, vscode.TextEditorDecorationType] => { 34 ): [string, vscode.TextEditorDecorationType] => {
34 const color = new vscode.ThemeColor('ralsp.' + tag); 35 const color = new vscode.ThemeColor('ralsp.' + tag);
35 const decor = vscode.window.createTextEditorDecorationType({ 36 const decor = vscode.window.createTextEditorDecorationType({
36 color 37 color,
38 textDecoration
37 }); 39 });
38 return [tag, decor]; 40 return [tag, decor];
39 }; 41 };
@@ -41,24 +43,24 @@ export class Highlighter {
41 const decorations: Iterable< 43 const decorations: Iterable<
42 [string, vscode.TextEditorDecorationType] 44 [string, vscode.TextEditorDecorationType]
43 > = [ 45 > = [
44 colorContrib('comment'), 46 decoration('comment'),
45 colorContrib('string'), 47 decoration('string'),
46 colorContrib('keyword'), 48 decoration('keyword'),
47 colorContrib('keyword.control'), 49 decoration('keyword.control'),
48 colorContrib('keyword.unsafe'), 50 decoration('keyword.unsafe'),
49 colorContrib('function'), 51 decoration('function'),
50 colorContrib('parameter'), 52 decoration('parameter'),
51 colorContrib('constant'), 53 decoration('constant'),
52 colorContrib('type'), 54 decoration('type'),
53 colorContrib('builtin'), 55 decoration('builtin'),
54 colorContrib('text'), 56 decoration('text'),
55 colorContrib('attribute'), 57 decoration('attribute'),
56 colorContrib('literal'), 58 decoration('literal'),
57 colorContrib('macro'), 59 decoration('macro'),
58 colorContrib('variable'), 60 decoration('variable'),
59 colorContrib('variable.mut'), 61 decoration('variable.mut', 'underline'),
60 colorContrib('field'), 62 decoration('field'),
61 colorContrib('module') 63 decoration('module')
62 ]; 64 ];
63 65
64 return new Map<string, vscode.TextEditorDecorationType>(decorations); 66 return new Map<string, vscode.TextEditorDecorationType>(decorations);
@@ -92,7 +94,10 @@ export class Highlighter {
92 } 94 }
93 95
94 const byTag: Map<string, vscode.Range[]> = new Map(); 96 const byTag: Map<string, vscode.Range[]> = new Map();
95 const colorfulIdents: Map<string, vscode.Range[]> = new Map(); 97 const colorfulIdents: Map<
98 string,
99 [vscode.Range[], boolean]
100 > = new Map();
96 const rainbowTime = Server.config.rainbowHighlightingOn; 101 const rainbowTime = Server.config.rainbowHighlightingOn;
97 102
98 for (const tag of this.decorations.keys()) { 103 for (const tag of this.decorations.keys()) {
@@ -106,10 +111,11 @@ export class Highlighter {
106 111
107 if (rainbowTime && d.bindingHash) { 112 if (rainbowTime && d.bindingHash) {
108 if (!colorfulIdents.has(d.bindingHash)) { 113 if (!colorfulIdents.has(d.bindingHash)) {
109 colorfulIdents.set(d.bindingHash, []); 114 const mut = d.tag.endsWith('.mut');
115 colorfulIdents.set(d.bindingHash, [[], mut]);
110 } 116 }
111 colorfulIdents 117 colorfulIdents
112 .get(d.bindingHash)! 118 .get(d.bindingHash)![0]
113 .push( 119 .push(
114 Server.client.protocol2CodeConverter.asRange(d.range) 120 Server.client.protocol2CodeConverter.asRange(d.range)
115 ); 121 );
@@ -130,10 +136,11 @@ export class Highlighter {
130 editor.setDecorations(dec, ranges); 136 editor.setDecorations(dec, ranges);
131 } 137 }
132 138
133 for (const [hash, ranges] of colorfulIdents.entries()) { 139 for (const [hash, [ranges, mut]] of colorfulIdents.entries()) {
140 const textDecoration = mut ? 'underline' : undefined;
134 const dec = vscode.window.createTextEditorDecorationType({ 141 const dec = vscode.window.createTextEditorDecorationType({
135 light: { color: fancify(hash, 'light') }, 142 light: { color: fancify(hash, 'light'), textDecoration },
136 dark: { color: fancify(hash, 'dark') } 143 dark: { color: fancify(hash, 'dark'), textDecoration }
137 }); 144 });
138 editor.setDecorations(dec, ranges); 145 editor.setDecorations(dec, ranges);
139 } 146 }