diff options
author | Aleksey Kladov <[email protected]> | 2019-12-30 21:18:16 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-30 21:20:04 +0000 |
commit | 23bac120625ca96402426e241c91ed5f3d7ccc02 (patch) | |
tree | 271429fe8639f603a91dd20cfdd950a3f5887e12 /editors/code/src/ctx.ts | |
parent | 08c5d157f9a24f0094c90c556019a20bf85e5a07 (diff) |
Retry inlay hints on content modified error
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r-- | editors/code/src/ctx.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index ca4319064..75b3542f4 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts | |||
@@ -61,6 +61,21 @@ export class Ctx { | |||
61 | pushCleanup(d: { dispose(): any }) { | 61 | pushCleanup(d: { dispose(): any }) { |
62 | this.extCtx.subscriptions.push(d); | 62 | this.extCtx.subscriptions.push(d); |
63 | } | 63 | } |
64 | |||
65 | async sendRequestWithRetry<R>(method: string, param: any): Promise<R> { | ||
66 | await this.client.onReady(); | ||
67 | const nRetries = 3; | ||
68 | for (let triesLeft = nRetries; ; triesLeft--) { | ||
69 | try { | ||
70 | return await this.client.sendRequest(method, param); | ||
71 | } catch (e) { | ||
72 | if (e.code === lc.ErrorCodes.ContentModified && triesLeft > 0) { | ||
73 | continue; | ||
74 | } | ||
75 | throw e; | ||
76 | } | ||
77 | } | ||
78 | } | ||
64 | } | 79 | } |
65 | 80 | ||
66 | export type Cmd = (...args: any[]) => any; | 81 | export type Cmd = (...args: any[]) => any; |