aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-02-05 20:39:47 +0000
committerVeetaha <[email protected]>2020-02-05 20:39:47 +0000
commit8153b60e1d8abdcefbf6c7c9657f1ce65a216d7a (patch)
tree68f445e973268dffce86c66cfc396c9221bf4ca3 /editors/code/src
parent8d0f7da2f5f2ae1dc5711005f08fde0007da165b (diff)
vscode: eliminate floating promises and insane amount of resource handle leaks
Diffstat (limited to 'editors/code/src')
-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
6 files changed, 33 insertions, 19 deletions
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 fc21c8813..585229ed0 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 66216e0fc..22458a391 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;