aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts22
1 files changed, 14 insertions, 8 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index a2a4e42a9..05d21ae56 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,5 +1,6 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3
3import { Config } from './config'; 4import { Config } from './config';
4import { createClient } from './client'; 5import { createClient } from './client';
5 6
@@ -20,7 +21,7 @@ export class Ctx {
20 } 21 }
21 22
22 async restartServer() { 23 async restartServer() {
23 let old = this.client; 24 const old = this.client;
24 if (old) { 25 if (old) {
25 await old.stop(); 26 await old.stop();
26 } 27 }
@@ -52,12 +53,12 @@ export class Ctx {
52 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { 53 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) {
53 const defaultCmd = `default:${name}`; 54 const defaultCmd = `default:${name}`;
54 const override = factory(this); 55 const override = factory(this);
55 const original = (...args: any[]) => 56 const original = (...args: unknown[]) =>
56 vscode.commands.executeCommand(defaultCmd, ...args); 57 vscode.commands.executeCommand(defaultCmd, ...args);
57 try { 58 try {
58 const d = vscode.commands.registerCommand( 59 const d = vscode.commands.registerCommand(
59 name, 60 name,
60 async (...args: any[]) => { 61 async (...args: unknown[]) => {
61 if (!(await override(...args))) { 62 if (!(await override(...args))) {
62 return await original(...args); 63 return await original(...args);
63 } 64 }
@@ -66,16 +67,18 @@ export class Ctx {
66 this.pushCleanup(d); 67 this.pushCleanup(d);
67 } catch (_) { 68 } catch (_) {
68 vscode.window.showWarningMessage( 69 vscode.window.showWarningMessage(
69 'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings', 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',
70 ); 73 );
71 } 74 }
72 } 75 }
73 76
74 get subscriptions(): { dispose(): any }[] { 77 get subscriptions(): Disposable[] {
75 return this.extCtx.subscriptions; 78 return this.extCtx.subscriptions;
76 } 79 }
77 80
78 pushCleanup(d: { dispose(): any }) { 81 pushCleanup(d: Disposable) {
79 this.extCtx.subscriptions.push(d); 82 this.extCtx.subscriptions.push(d);
80 } 83 }
81 84
@@ -84,12 +87,15 @@ export class Ctx {
84 } 87 }
85} 88}
86 89
87export type Cmd = (...args: any[]) => any; 90export interface Disposable {
91 dispose(): void;
92}
93export type Cmd = (...args: any[]) => unknown;
88 94
89export async function sendRequestWithRetry<R>( 95export async function sendRequestWithRetry<R>(
90 client: lc.LanguageClient, 96 client: lc.LanguageClient,
91 method: string, 97 method: string,
92 param: any, 98 param: unknown,
93 token?: vscode.CancellationToken, 99 token?: vscode.CancellationToken,
94): Promise<R> { 100): Promise<R> {
95 for (const delay of [2, 4, 6, 8, 10, null]) { 101 for (const delay of [2, 4, 6, 8, 10, null]) {