aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-30 22:12:33 +0000
committerAleksey Kladov <[email protected]>2019-12-30 22:17:56 +0000
commit233f1dd2a850a7c8c6947c88c1ce06f7a945befd (patch)
tree0e6c920b9bb1955de444dc360072b2256060d89b /editors/code/src/ctx.ts
parentcdd7118cbf23e21c376092b3b2734407004b8dbf (diff)
Privatize highlighting
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts17
1 files changed, 12 insertions, 5 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index d3ef27e43..39eddfcbd 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -62,23 +62,30 @@ export class Ctx {
62 this.extCtx.subscriptions.push(d); 62 this.extCtx.subscriptions.push(d);
63 } 63 }
64 64
65 async sendRequestWithRetry<R>(method: string, param: any, token: vscode.CancellationToken): Promise<R> { 65 async sendRequestWithRetry<R>(
66 method: string,
67 param: any,
68 token: vscode.CancellationToken,
69 ): Promise<R> {
66 await this.client.onReady(); 70 await this.client.onReady();
67 for (const delay of [2, 4, 6, 8, 10, null]) { 71 for (const delay of [2, 4, 6, 8, 10, null]) {
68 try { 72 try {
69 return await this.client.sendRequest(method, param, token); 73 return await this.client.sendRequest(method, param, token);
70 } catch (e) { 74 } catch (e) {
71 if (e.code === lc.ErrorCodes.ContentModified && delay !== null) { 75 if (
72 await sleep(10 * (1 << delay)) 76 e.code === lc.ErrorCodes.ContentModified &&
77 delay !== null
78 ) {
79 await sleep(10 * (1 << delay));
73 continue; 80 continue;
74 } 81 }
75 throw e; 82 throw e;
76 } 83 }
77 } 84 }
78 throw 'unreachable' 85 throw 'unreachable';
79 } 86 }
80} 87}
81 88
82export type Cmd = (...args: any[]) => any; 89export type Cmd = (...args: any[]) => any;
83 90
84const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) 91const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));