diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package-lock.json | 81 | ||||
-rw-r--r-- | editors/code/package.json | 34 | ||||
-rw-r--r-- | editors/code/rollup.config.js | 4 | ||||
-rw-r--r-- | editors/code/src/commands/on_enter.ts | 45 | ||||
-rw-r--r-- | editors/code/src/ctx.ts | 24 | ||||
-rw-r--r-- | editors/code/src/highlighting.ts | 25 | ||||
-rw-r--r-- | editors/code/src/main.ts | 4 | ||||
-rw-r--r-- | editors/code/tsconfig.json | 6 |
8 files changed, 102 insertions, 121 deletions
diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index 4096255ac..353af06bf 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json | |||
@@ -25,56 +25,49 @@ | |||
25 | } | 25 | } |
26 | }, | 26 | }, |
27 | "@rollup/plugin-commonjs": { | 27 | "@rollup/plugin-commonjs": { |
28 | "version": "11.0.1", | 28 | "version": "11.0.2", |
29 | "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.1.tgz", | 29 | "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.0.2.tgz", |
30 | "integrity": "sha512-SaVUoaLDg3KnIXC5IBNIspr1APTYDzk05VaYcI6qz+0XX3ZlSCwAkfAhNSOxfd5GAdcm/63Noi4TowOY9MpcDg==", | 30 | "integrity": "sha512-MPYGZr0qdbV5zZj8/2AuomVpnRVXRU5XKXb3HVniwRoRCreGlf5kOE081isNWeiLIi6IYkwTX9zE0/c7V8g81g==", |
31 | "dev": true, | 31 | "dev": true, |
32 | "requires": { | 32 | "requires": { |
33 | "@rollup/pluginutils": "^3.0.0", | 33 | "@rollup/pluginutils": "^3.0.0", |
34 | "estree-walker": "^0.6.1", | 34 | "estree-walker": "^1.0.1", |
35 | "is-reference": "^1.1.2", | 35 | "is-reference": "^1.1.2", |
36 | "magic-string": "^0.25.2", | 36 | "magic-string": "^0.25.2", |
37 | "resolve": "^1.11.0" | 37 | "resolve": "^1.11.0" |
38 | } | 38 | } |
39 | }, | 39 | }, |
40 | "@rollup/plugin-node-resolve": { | 40 | "@rollup/plugin-node-resolve": { |
41 | "version": "6.1.0", | 41 | "version": "7.1.1", |
42 | "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-6.1.0.tgz", | 42 | "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.1.tgz", |
43 | "integrity": "sha512-Cv7PDIvxdE40SWilY5WgZpqfIUEaDxFxs89zCAHjqyRwlTSuql4M5hjIuc5QYJkOH0/vyiyNXKD72O+LhRipGA==", | 43 | "integrity": "sha512-14ddhD7TnemeHE97a4rLOhobfYvUVcaYuqTnL8Ti7Jxi9V9Jr5LY7Gko4HZ5k4h4vqQM0gBQt6tsp9xXW94WPA==", |
44 | "dev": true, | 44 | "dev": true, |
45 | "requires": { | 45 | "requires": { |
46 | "@rollup/pluginutils": "^3.0.0", | 46 | "@rollup/pluginutils": "^3.0.6", |
47 | "@types/resolve": "0.0.8", | 47 | "@types/resolve": "0.0.8", |
48 | "builtin-modules": "^3.1.0", | 48 | "builtin-modules": "^3.1.0", |
49 | "is-module": "^1.0.0", | 49 | "is-module": "^1.0.0", |
50 | "resolve": "^1.11.1" | 50 | "resolve": "^1.14.2" |
51 | } | 51 | }, |
52 | }, | 52 | "dependencies": { |
53 | "@rollup/plugin-typescript": { | 53 | "resolve": { |
54 | "version": "3.0.0", | 54 | "version": "1.15.0", |
55 | "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-3.0.0.tgz", | 55 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", |
56 | "integrity": "sha512-O6915Ril3+Q0B4P898PULAcPFZfPuatEB/4nox7bnK48ekGrmamMYhMB5tOqWjihEWrw4oz/NL+c+/kS3Fk95g==", | 56 | "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", |
57 | "dev": true, | 57 | "dev": true, |
58 | "requires": { | 58 | "requires": { |
59 | "@rollup/pluginutils": "^3.0.1", | 59 | "path-parse": "^1.0.6" |
60 | "resolve": "^1.14.1" | 60 | } |
61 | } | ||
61 | } | 62 | } |
62 | }, | 63 | }, |
63 | "@rollup/pluginutils": { | 64 | "@rollup/pluginutils": { |
64 | "version": "3.0.6", | 65 | "version": "3.0.8", |
65 | "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.6.tgz", | 66 | "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.8.tgz", |
66 | "integrity": "sha512-Nb6U7sg11v8D+E4mxRxwT+UumUL7MSnwI8V1SJB3THyW2MOGD/Q6GyxLtpnjrbT3zTRPSozzDMyVZwemgldO3w==", | 67 | "integrity": "sha512-rYGeAc4sxcZ+kPG/Tw4/fwJODC3IXHYDH4qusdN/b6aLw5LPUbzpecYbEJh4sVQGPFJxd2dBU4kc1H3oy9/bnw==", |
67 | "dev": true, | 68 | "dev": true, |
68 | "requires": { | 69 | "requires": { |
69 | "estree-walker": "^1.0.1" | 70 | "estree-walker": "^1.0.1" |
70 | }, | ||
71 | "dependencies": { | ||
72 | "estree-walker": { | ||
73 | "version": "1.0.1", | ||
74 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", | ||
75 | "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", | ||
76 | "dev": true | ||
77 | } | ||
78 | } | 71 | } |
79 | }, | 72 | }, |
80 | "@types/estree": { | 73 | "@types/estree": { |
@@ -98,12 +91,6 @@ | |||
98 | "@types/node": "*" | 91 | "@types/node": "*" |
99 | } | 92 | } |
100 | }, | 93 | }, |
101 | "@types/seedrandom": { | ||
102 | "version": "2.4.28", | ||
103 | "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-2.4.28.tgz", | ||
104 | "integrity": "sha512-SMA+fUwULwK7sd/ZJicUztiPs8F1yCPwF3O23Z9uQ32ME5Ha0NmDK9+QTsYE4O2tHXChzXomSWWeIhCnoN1LqA==", | ||
105 | "dev": true | ||
106 | }, | ||
107 | "@types/vscode": { | 94 | "@types/vscode": { |
108 | "version": "1.41.0", | 95 | "version": "1.41.0", |
109 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.41.0.tgz", | 96 | "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.41.0.tgz", |
@@ -348,9 +335,9 @@ | |||
348 | "dev": true | 335 | "dev": true |
349 | }, | 336 | }, |
350 | "estree-walker": { | 337 | "estree-walker": { |
351 | "version": "0.6.1", | 338 | "version": "1.0.1", |
352 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", | 339 | "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", |
353 | "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", | 340 | "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", |
354 | "dev": true | 341 | "dev": true |
355 | }, | 342 | }, |
356 | "esutils": { | 343 | "esutils": { |
@@ -675,9 +662,9 @@ | |||
675 | } | 662 | } |
676 | }, | 663 | }, |
677 | "rollup": { | 664 | "rollup": { |
678 | "version": "1.30.1", | 665 | "version": "1.31.0", |
679 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.30.1.tgz", | 666 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.31.0.tgz", |
680 | "integrity": "sha512-Uus8mwQXwaO+ZVoNwBcXKhT0AvycFCBW/W8VZtkpVGsotRllWk9oldfCjqWmTnFRI0y7x6BnEqSqc65N+/YdBw==", | 667 | "integrity": "sha512-9C6ovSyNeEwvuRuUUmsTpJcXac1AwSL1a3x+O5lpmQKZqi5mmrjauLeqIjvREC+yNRR8fPdzByojDng+af3nVw==", |
681 | "dev": true, | 668 | "dev": true, |
682 | "requires": { | 669 | "requires": { |
683 | "@types/estree": "*", | 670 | "@types/estree": "*", |
@@ -691,11 +678,6 @@ | |||
691 | "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", | 678 | "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", |
692 | "dev": true | 679 | "dev": true |
693 | }, | 680 | }, |
694 | "seedrandom": { | ||
695 | "version": "3.0.5", | ||
696 | "resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz", | ||
697 | "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" | ||
698 | }, | ||
699 | "semver": { | 681 | "semver": { |
700 | "version": "6.3.0", | 682 | "version": "6.3.0", |
701 | "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", | 683 | "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", |
@@ -749,7 +731,8 @@ | |||
749 | "tslib": { | 731 | "tslib": { |
750 | "version": "1.10.0", | 732 | "version": "1.10.0", |
751 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", | 733 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", |
752 | "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" | 734 | "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", |
735 | "dev": true | ||
753 | }, | 736 | }, |
754 | "tslint": { | 737 | "tslint": { |
755 | "version": "5.20.1", | 738 | "version": "5.20.1", |
@@ -895,7 +878,7 @@ | |||
895 | "vscode-languageclient": { | 878 | "vscode-languageclient": { |
896 | "version": "6.1.0", | 879 | "version": "6.1.0", |
897 | "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.0.tgz", | 880 | "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.0.tgz", |
898 | "integrity": "sha1-7mfAt4GMQs4CgVctBcia38xPWjg=", | 881 | "integrity": "sha512-Tcp0VoOaa0YzxL4nEfK9tsmcy76Eo8jNLvFQZwh2c8oMm02luL8uGYPLQNAiZ3XGgegfcwiQFZMqbW7DNV0vxA==", |
899 | "requires": { | 882 | "requires": { |
900 | "semver": "^6.3.0", | 883 | "semver": "^6.3.0", |
901 | "vscode-languageserver-protocol": "^3.15.2" | 884 | "vscode-languageserver-protocol": "^3.15.2" |
diff --git a/editors/code/package.json b/editors/code/package.json index e733ee2b4..c9404a4dd 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -18,28 +18,25 @@ | |||
18 | "vscode": "^1.41.0" | 18 | "vscode": "^1.41.0" |
19 | }, | 19 | }, |
20 | "scripts": { | 20 | "scripts": { |
21 | "vscode:prepublish": "rollup -c", | 21 | "vscode:prepublish": "tsc && rollup -c", |
22 | "package": "vsce package", | 22 | "package": "vsce package", |
23 | "watch": "tsc -watch -p ./", | 23 | "watch": "tsc --watch", |
24 | "fmt": "tsfmt -r && tslint -c tslint.json 'src/**/*.ts' --fix" | 24 | "fmt": "tsfmt -r && tslint -c tslint.json 'src/**/*.ts' --fix" |
25 | }, | 25 | }, |
26 | "dependencies": { | 26 | "dependencies": { |
27 | "jsonc-parser": "^2.1.0", | 27 | "jsonc-parser": "^2.1.0", |
28 | "seedrandom": "^3.0.5", | 28 | "vscode-languageclient": "^6.1.0" |
29 | "vscode-languageclient": "^6.1.0", | ||
30 | "tslib": "^1.10.0" | ||
31 | }, | 29 | }, |
32 | "devDependencies": { | 30 | "devDependencies": { |
33 | "@rollup/plugin-commonjs": "^11.0.1", | 31 | "@rollup/plugin-commonjs": "^11.0.2", |
34 | "@rollup/plugin-node-resolve": "^6.1.0", | 32 | "@rollup/plugin-node-resolve": "^7.1.1", |
35 | "@rollup/plugin-typescript": "^3.0.0", | ||
36 | "@types/node": "^12.12.25", | 33 | "@types/node": "^12.12.25", |
37 | "@types/seedrandom": "^2.4.28", | ||
38 | "@types/vscode": "^1.41.0", | 34 | "@types/vscode": "^1.41.0", |
39 | "rollup": "^1.30.1", | 35 | "rollup": "^1.31.0", |
36 | "tslib": "^1.10.0", | ||
40 | "tslint": "^5.20.1", | 37 | "tslint": "^5.20.1", |
41 | "typescript": "^3.7.5", | ||
42 | "typescript-formatter": "^7.2.2", | 38 | "typescript-formatter": "^7.2.2", |
39 | "typescript": "^3.7.5", | ||
43 | "vsce": "^1.71.0" | 40 | "vsce": "^1.71.0" |
44 | }, | 41 | }, |
45 | "activationEvents": [ | 42 | "activationEvents": [ |
@@ -117,6 +114,11 @@ | |||
117 | "command": "rust-analyzer.reload", | 114 | "command": "rust-analyzer.reload", |
118 | "title": "Restart server", | 115 | "title": "Restart server", |
119 | "category": "Rust Analyzer" | 116 | "category": "Rust Analyzer" |
117 | }, | ||
118 | { | ||
119 | "command": "rust-analyzer.onEnter", | ||
120 | "title": "Enhanced enter key", | ||
121 | "category": "Rust Analyzer" | ||
120 | } | 122 | } |
121 | ], | 123 | ], |
122 | "keybindings": [ | 124 | "keybindings": [ |
@@ -139,6 +141,11 @@ | |||
139 | "command": "rust-analyzer.run", | 141 | "command": "rust-analyzer.run", |
140 | "key": "ctrl+r", | 142 | "key": "ctrl+r", |
141 | "when": "editorTextFocus && editorLangId == rust" | 143 | "when": "editorTextFocus && editorLangId == rust" |
144 | }, | ||
145 | { | ||
146 | "command": "rust-analyzer.onEnter", | ||
147 | "key": "enter", | ||
148 | "when": "editorTextFocus && !suggestWidgetVisible && editorLangId == rust" | ||
142 | } | 149 | } |
143 | ], | 150 | ], |
144 | "configuration": { | 151 | "configuration": { |
@@ -160,11 +167,6 @@ | |||
160 | "default": {}, | 167 | "default": {}, |
161 | "description": "Fine grained feature flags to disable annoying features" | 168 | "description": "Fine grained feature flags to disable annoying features" |
162 | }, | 169 | }, |
163 | "rust-analyzer.enableEnhancedTyping": { | ||
164 | "type": "boolean", | ||
165 | "default": true, | ||
166 | "description": "Enables enhanced typing. NOTE: If using a VIM extension, you should set this to false" | ||
167 | }, | ||
168 | "rust-analyzer.raLspServerPath": { | 170 | "rust-analyzer.raLspServerPath": { |
169 | "type": [ | 171 | "type": [ |
170 | "string" | 172 | "string" |
diff --git a/editors/code/rollup.config.js b/editors/code/rollup.config.js index de6a3b2b7..f8d320f46 100644 --- a/editors/code/rollup.config.js +++ b/editors/code/rollup.config.js | |||
@@ -1,12 +1,10 @@ | |||
1 | import typescript from '@rollup/plugin-typescript'; | ||
2 | import resolve from '@rollup/plugin-node-resolve'; | 1 | import resolve from '@rollup/plugin-node-resolve'; |
3 | import commonjs from '@rollup/plugin-commonjs'; | 2 | import commonjs from '@rollup/plugin-commonjs'; |
4 | import nodeBuiltins from 'builtin-modules'; | 3 | import nodeBuiltins from 'builtin-modules'; |
5 | 4 | ||
6 | export default { | 5 | export default { |
7 | input: 'src/main.ts', | 6 | input: 'out/main.js', |
8 | plugins: [ | 7 | plugins: [ |
9 | typescript(), | ||
10 | resolve({ | 8 | resolve({ |
11 | preferBuiltins: true | 9 | preferBuiltins: true |
12 | }), | 10 | }), |
diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts index 6f61883cd..c636234da 100644 --- a/editors/code/src/commands/on_enter.ts +++ b/editors/code/src/commands/on_enter.ts | |||
@@ -1,28 +1,35 @@ | |||
1 | import * as vscode from 'vscode'; | ||
1 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
2 | 3 | ||
3 | import { applySourceChange, SourceChange } from '../source_change'; | 4 | import { applySourceChange, SourceChange } from '../source_change'; |
4 | import { Cmd, Ctx } from '../ctx'; | 5 | import { Cmd, Ctx } from '../ctx'; |
5 | 6 | ||
6 | export function onEnter(ctx: Ctx): Cmd { | 7 | async function handleKeypress(ctx: Ctx) { |
7 | return async (event: { text: string }) => { | 8 | const editor = ctx.activeRustEditor; |
8 | const editor = ctx.activeRustEditor; | 9 | const client = ctx.client; |
9 | const client = ctx.client; | 10 | if (!editor) return false; |
10 | if (!editor || event.text !== '\n') return false; | 11 | if (!editor || !client) return false; |
11 | if (!client) return false; | 12 | |
13 | const request: lc.TextDocumentPositionParams = { | ||
14 | textDocument: { uri: editor.document.uri.toString() }, | ||
15 | position: client.code2ProtocolConverter.asPosition( | ||
16 | editor.selection.active, | ||
17 | ), | ||
18 | }; | ||
19 | const change = await client.sendRequest<undefined | SourceChange>( | ||
20 | 'rust-analyzer/onEnter', | ||
21 | request, | ||
22 | ); | ||
23 | if (!change) return false; | ||
12 | 24 | ||
13 | const request: lc.TextDocumentPositionParams = { | 25 | await applySourceChange(ctx, change); |
14 | textDocument: { uri: editor.document.uri.toString() }, | 26 | return true; |
15 | position: client.code2ProtocolConverter.asPosition( | 27 | } |
16 | editor.selection.active, | 28 | |
17 | ), | 29 | export function onEnter(ctx: Ctx): Cmd { |
18 | }; | 30 | return async () => { |
19 | const change = await client.sendRequest<undefined | SourceChange>( | 31 | if (await handleKeypress(ctx)) return; |
20 | 'rust-analyzer/onEnter', | ||
21 | request, | ||
22 | ); | ||
23 | if (!change) return false; | ||
24 | 32 | ||
25 | await applySourceChange(ctx, change); | 33 | await vscode.commands.executeCommand('default:type', { text: '\n' }); |
26 | return true; | ||
27 | }; | 34 | }; |
28 | } | 35 | } |
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 05d21ae56..aa75943bf 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts | |||
@@ -50,30 +50,6 @@ export class Ctx { | |||
50 | this.pushCleanup(d); | 50 | this.pushCleanup(d); |
51 | } | 51 | } |
52 | 52 | ||
53 | overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { | ||
54 | const defaultCmd = `default:${name}`; | ||
55 | const override = factory(this); | ||
56 | const original = (...args: unknown[]) => | ||
57 | vscode.commands.executeCommand(defaultCmd, ...args); | ||
58 | try { | ||
59 | const d = vscode.commands.registerCommand( | ||
60 | name, | ||
61 | async (...args: unknown[]) => { | ||
62 | if (!(await override(...args))) { | ||
63 | return await original(...args); | ||
64 | } | ||
65 | }, | ||
66 | ); | ||
67 | this.pushCleanup(d); | ||
68 | } catch (_) { | ||
69 | vscode.window.showWarningMessage( | ||
70 | 'Enhanced typing feature is disabled because of incompatibility ' + | ||
71 | 'with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: ' + | ||
72 | 'https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings', | ||
73 | ); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | get subscriptions(): Disposable[] { | 53 | get subscriptions(): Disposable[] { |
78 | return this.extCtx.subscriptions; | 54 | return this.extCtx.subscriptions; |
79 | } | 55 | } |
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 3d190c3ad..66216e0fc 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
2 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
3 | import seedrandom from 'seedrandom'; | ||
4 | 3 | ||
5 | import { ColorTheme, TextMateRuleSettings } from './color_theme'; | 4 | import { ColorTheme, TextMateRuleSettings } from './color_theme'; |
6 | 5 | ||
@@ -70,9 +69,9 @@ interface Decoration { | |||
70 | 69 | ||
71 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 | 70 | // Based on this HSL-based color generator: https://gist.github.com/bendc/76c48ce53299e6078a76 |
72 | function fancify(seed: string, shade: 'light' | 'dark') { | 71 | function fancify(seed: string, shade: 'light' | 'dark') { |
73 | const random = seedrandom(seed); | 72 | const random = randomU32Numbers(hashString(seed)) |
74 | const randomInt = (min: number, max: number) => { | 73 | const randomInt = (min: number, max: number) => { |
75 | return Math.floor(random() * (max - min + 1)) + min; | 74 | return Math.abs(random()) % (max - min + 1) + min; |
76 | }; | 75 | }; |
77 | 76 | ||
78 | const h = randomInt(0, 360); | 77 | const h = randomInt(0, 360); |
@@ -246,3 +245,23 @@ const TAG_TO_SCOPES = new Map<string, string[]>([ | |||
246 | ["keyword.unsafe", ["keyword.other.unsafe"]], | 245 | ["keyword.unsafe", ["keyword.other.unsafe"]], |
247 | ["keyword.control", ["keyword.control"]], | 246 | ["keyword.control", ["keyword.control"]], |
248 | ]); | 247 | ]); |
248 | |||
249 | function randomU32Numbers(seed: number) { | ||
250 | let random = seed | 0; | ||
251 | return () => { | ||
252 | random ^= random << 13; | ||
253 | random ^= random >> 17; | ||
254 | random ^= random << 5; | ||
255 | random |= 0; | ||
256 | return random | ||
257 | } | ||
258 | } | ||
259 | |||
260 | function hashString(str: string): number { | ||
261 | let res = 0; | ||
262 | for (let i = 0; i < str.length; ++i) { | ||
263 | const c = str.codePointAt(i)!!; | ||
264 | res = (res * 31 + c) & ~0; | ||
265 | } | ||
266 | return res; | ||
267 | } | ||
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 6813c3c4c..efc31b2e2 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -21,6 +21,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
21 | ctx.registerCommand('expandMacro', commands.expandMacro); | 21 | ctx.registerCommand('expandMacro', commands.expandMacro); |
22 | ctx.registerCommand('run', commands.run); | 22 | ctx.registerCommand('run', commands.run); |
23 | ctx.registerCommand('reload', commands.reload); | 23 | ctx.registerCommand('reload', commands.reload); |
24 | ctx.registerCommand('onEnter', commands.onEnter); | ||
24 | 25 | ||
25 | // Internal commands which are invoked by the server. | 26 | // Internal commands which are invoked by the server. |
26 | ctx.registerCommand('runSingle', commands.runSingle); | 27 | ctx.registerCommand('runSingle', commands.runSingle); |
@@ -28,9 +29,6 @@ export async function activate(context: vscode.ExtensionContext) { | |||
28 | ctx.registerCommand('applySourceChange', commands.applySourceChange); | 29 | ctx.registerCommand('applySourceChange', commands.applySourceChange); |
29 | ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); | 30 | ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); |
30 | 31 | ||
31 | if (ctx.config.enableEnhancedTyping) { | ||
32 | ctx.overrideCommand('type', commands.onEnter); | ||
33 | } | ||
34 | activateStatusDisplay(ctx); | 32 | activateStatusDisplay(ctx); |
35 | 33 | ||
36 | activateHighlighting(ctx); | 34 | activateHighlighting(ctx); |
diff --git a/editors/code/tsconfig.json b/editors/code/tsconfig.json index 1740abb2e..e60eb8e5e 100644 --- a/editors/code/tsconfig.json +++ b/editors/code/tsconfig.json | |||
@@ -1,6 +1,6 @@ | |||
1 | { | 1 | { |
2 | "compilerOptions": { | 2 | "compilerOptions": { |
3 | "module": "es2015", | 3 | "module": "commonjs", |
4 | "target": "es2018", | 4 | "target": "es2018", |
5 | "outDir": "out", | 5 | "outDir": "out", |
6 | "lib": [ | 6 | "lib": [ |
@@ -13,9 +13,7 @@ | |||
13 | "noUnusedParameters": true, | 13 | "noUnusedParameters": true, |
14 | "noImplicitReturns": true, | 14 | "noImplicitReturns": true, |
15 | "noFallthroughCasesInSwitch": true, | 15 | "noFallthroughCasesInSwitch": true, |
16 | "newLine": "LF", | 16 | "newLine": "LF" |
17 | "esModuleInterop": true, | ||
18 | "importHelpers": true | ||
19 | }, | 17 | }, |
20 | "exclude": [ | 18 | "exclude": [ |
21 | "node_modules" | 19 | "node_modules" |