aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-05 20:57:08 +0000
committerGitHub <[email protected]>2020-02-05 20:57:08 +0000
commitea9d18ba836a7228f7310e1bc77c0918f0191a42 (patch)
tree64b3cabe122d06484a521ff2428f2ca1e4df1d48 /editors/code
parent2471b6bc3a318d7303d0556c85940090b6cf6d7a (diff)
parent8153b60e1d8abdcefbf6c7c9657f1ce65a216d7a (diff)
Merge #3024
3024: vscode: eliminate floating promises and insane amount of resource handle leaks r=matklad a=Veetaha Khm, yeah ... Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/package.json2
-rw-r--r--editors/code/src/commands/index.ts2
-rw-r--r--editors/code/src/commands/syntax_tree.ts2
-rw-r--r--editors/code/src/config.ts2
-rw-r--r--editors/code/src/highlighting.ts2
-rw-r--r--editors/code/src/inlay_hints.ts34
-rw-r--r--editors/code/src/status_display.ts10
-rw-r--r--editors/code/tslint.json3
8 files changed, 36 insertions, 21 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index c9404a4dd..11d37053e 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -21,7 +21,7 @@
21 "vscode:prepublish": "tsc && rollup -c", 21 "vscode:prepublish": "tsc && rollup -c",
22 "package": "vsce package", 22 "package": "vsce package",
23 "watch": "tsc --watch", 23 "watch": "tsc --watch",
24 "fmt": "tsfmt -r && tslint -c tslint.json 'src/**/*.ts' --fix" 24 "fmt": "tsfmt -r && tslint -p tsconfig.json -c tslint.json 'src/**/*.ts' --fix"
25 }, 25 },
26 "dependencies": { 26 "dependencies": {
27 "jsonc-parser": "^2.1.0", 27 "jsonc-parser": "^2.1.0",
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts
index 5a4c1df5e..aee969432 100644
--- a/editors/code/src/commands/index.ts
+++ b/editors/code/src/commands/index.ts
@@ -35,7 +35,7 @@ export function showReferences(ctx: Ctx): Cmd {
35 35
36export function applySourceChange(ctx: Ctx): Cmd { 36export function applySourceChange(ctx: Ctx): Cmd {
37 return async (change: sourceChange.SourceChange) => { 37 return async (change: sourceChange.SourceChange) => {
38 sourceChange.applySourceChange(ctx, change); 38 await sourceChange.applySourceChange(ctx, change);
39 }; 39 };
40} 40}
41 41
diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts
index 211f2251f..7dde66ad1 100644
--- a/editors/code/src/commands/syntax_tree.ts
+++ b/editors/code/src/commands/syntax_tree.ts
@@ -22,6 +22,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
22 if (doc.languageId !== 'rust') return; 22 if (doc.languageId !== 'rust') return;
23 afterLs(() => tdcp.eventEmitter.fire(tdcp.uri)); 23 afterLs(() => tdcp.eventEmitter.fire(tdcp.uri));
24 }, 24 },
25 null,
25 ctx.subscriptions, 26 ctx.subscriptions,
26 ); 27 );
27 28
@@ -30,6 +31,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
30 if (!editor || editor.document.languageId !== 'rust') return; 31 if (!editor || editor.document.languageId !== 'rust') return;
31 tdcp.eventEmitter.fire(tdcp.uri); 32 tdcp.eventEmitter.fire(tdcp.uri);
32 }, 33 },
34 null,
33 ctx.subscriptions, 35 ctx.subscriptions,
34 ); 36 );
35 37
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index c750b2d5c..524620433 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -45,7 +45,7 @@ export class Config {
45 private prevCargoWatchOptions: null | CargoWatchOptions = null; 45 private prevCargoWatchOptions: null | CargoWatchOptions = null;
46 46
47 constructor(ctx: vscode.ExtensionContext) { 47 constructor(ctx: vscode.ExtensionContext) {
48 vscode.workspace.onDidChangeConfiguration(_ => this.refresh(), ctx.subscriptions); 48 vscode.workspace.onDidChangeConfiguration(_ => this.refresh(), null, ctx.subscriptions);
49 this.refresh(); 49 this.refresh();
50 } 50 }
51 51
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index e90fb8acc..4fbbe3ddc 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -32,6 +32,7 @@ export function activateHighlighting(ctx: Ctx) {
32 32
33 vscode.workspace.onDidChangeConfiguration( 33 vscode.workspace.onDidChangeConfiguration(
34 _ => highlighter.removeHighlights(), 34 _ => highlighter.removeHighlights(),
35 null,
35 ctx.subscriptions, 36 ctx.subscriptions,
36 ); 37 );
37 38
@@ -52,6 +53,7 @@ export function activateHighlighting(ctx: Ctx) {
52 ); 53 );
53 highlighter.setHighlights(editor, decorations); 54 highlighter.setHighlights(editor, decorations);
54 }, 55 },
56 null,
55 ctx.subscriptions, 57 ctx.subscriptions,
56 ); 58 );
57} 59}
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts
index ae7510183..1c019a51b 100644
--- a/editors/code/src/inlay_hints.ts
+++ b/editors/code/src/inlay_hints.ts
@@ -5,19 +5,27 @@ import { Ctx, sendRequestWithRetry } from './ctx';
5 5
6export function activateInlayHints(ctx: Ctx) { 6export function activateInlayHints(ctx: Ctx) {
7 const hintsUpdater = new HintsUpdater(ctx); 7 const hintsUpdater = new HintsUpdater(ctx);
8 vscode.window.onDidChangeVisibleTextEditors(async _ => { 8 vscode.window.onDidChangeVisibleTextEditors(
9 await hintsUpdater.refresh(); 9 async _ => hintsUpdater.refresh(),
10 }, ctx.subscriptions); 10 null,
11 11 ctx.subscriptions
12 vscode.workspace.onDidChangeTextDocument(async e => { 12 );
13 if (e.contentChanges.length === 0) return; 13
14 if (e.document.languageId !== 'rust') return; 14 vscode.workspace.onDidChangeTextDocument(
15 await hintsUpdater.refresh(); 15 async event => {
16 }, ctx.subscriptions); 16 if (event.contentChanges.length !== 0) return;
17 17 if (event.document.languageId !== 'rust') return;
18 vscode.workspace.onDidChangeConfiguration(_ => { 18 await hintsUpdater.refresh();
19 hintsUpdater.setEnabled(ctx.config.displayInlayHints); 19 },
20 }, ctx.subscriptions); 20 null,
21 ctx.subscriptions
22 );
23
24 vscode.workspace.onDidChangeConfiguration(
25 async _ => hintsUpdater.setEnabled(ctx.config.displayInlayHints),
26 null,
27 ctx.subscriptions
28 );
21 29
22 ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints)); 30 ctx.onDidRestart(_ => hintsUpdater.setEnabled(ctx.config.displayInlayHints));
23} 31}
diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts
index 4317410c7..51dbf388b 100644
--- a/editors/code/src/status_display.ts
+++ b/editors/code/src/status_display.ts
@@ -9,12 +9,14 @@ const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '
9export function activateStatusDisplay(ctx: Ctx) { 9export function activateStatusDisplay(ctx: Ctx) {
10 const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command); 10 const statusDisplay = new StatusDisplay(ctx.config.cargoWatchOptions.command);
11 ctx.pushCleanup(statusDisplay); 11 ctx.pushCleanup(statusDisplay);
12 ctx.onDidRestart(client => { 12 ctx.onDidRestart(client => ctx.pushCleanup(client.onProgress(
13 client.onProgress(WorkDoneProgress.type, 'rustAnalyzer/cargoWatcher', params => statusDisplay.handleProgressNotification(params)); 13 WorkDoneProgress.type,
14 }); 14 'rustAnalyzer/cargoWatcher',
15 params => statusDisplay.handleProgressNotification(params)
16 )));
15} 17}
16 18
17class StatusDisplay implements vscode.Disposable, Disposable { 19class StatusDisplay implements Disposable {
18 packageName?: string; 20 packageName?: string;
19 21
20 private i: number = 0; 22 private i: number = 0;
diff --git a/editors/code/tslint.json b/editors/code/tslint.json
index 0df11b2f1..333e2a321 100644
--- a/editors/code/tslint.json
+++ b/editors/code/tslint.json
@@ -4,6 +4,7 @@
4 true, 4 true,
5 "always" 5 "always"
6 ], 6 ],
7 "prefer-const": true 7 "prefer-const": true,
8 "no-floating-promises": true
8 } 9 }
9} 10}