aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorDmitry <[email protected]>2020-08-14 19:32:05 +0100
committerDmitry <[email protected]>2020-08-14 19:32:05 +0100
commit178c3e135a2a249692f7784712492e7884ae0c00 (patch)
treeac6b769dbf7162150caa0c1624786a4dd79ff3be /editors
parent06ff8e6c760ff05f10e868b5d1f9d79e42fbb49c (diff)
parentc2594daf2974dbd4ce3d9b7ec72481764abaceb5 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/client.ts10
-rw-r--r--editors/code/src/toolchain.ts4
-rw-r--r--editors/code/src/util.ts6
3 files changed, 7 insertions, 13 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 18948cb3c..f5db55b8c 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -4,7 +4,7 @@ import * as ra from '../src/lsp_ext';
4import * as Is from 'vscode-languageclient/lib/utils/is'; 4import * as Is from 'vscode-languageclient/lib/utils/is';
5 5
6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; 6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
7import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; 7import { SemanticTokensFeature } from 'vscode-languageclient/lib/semanticTokens.proposed';
8import { assert } from './util'; 8import { assert } from './util';
9 9
10function renderCommand(cmd: ra.CommandLink) { 10function renderCommand(cmd: ra.CommandLink) {
@@ -44,12 +44,6 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient
44 diagnosticCollectionName: "rustc", 44 diagnosticCollectionName: "rustc",
45 traceOutputChannel, 45 traceOutputChannel,
46 middleware: { 46 middleware: {
47 // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576
48 async provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature) {
49 const res = await next(document, token);
50 if (res === undefined) throw new Error('busy');
51 return res;
52 },
53 async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { 47 async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) {
54 return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( 48 return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then(
55 (result) => { 49 (result) => {
@@ -135,7 +129,7 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient
135 ); 129 );
136 } 130 }
137 131
138 } as any 132 }
139 }; 133 };
140 134
141 const client = new lc.LanguageClient( 135 const client = new lc.LanguageClient(
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts
index 80a7915e9..a5dc3cf0c 100644
--- a/editors/code/src/toolchain.ts
+++ b/editors/code/src/toolchain.ts
@@ -121,12 +121,12 @@ export class Cargo {
121 } 121 }
122} 122}
123 123
124/** Mirrors `ra_toolchain::cargo()` implementation */ 124/** Mirrors `toolchain::cargo()` implementation */
125export function cargoPath(): string { 125export function cargoPath(): string {
126 return getPathForExecutable("cargo"); 126 return getPathForExecutable("cargo");
127} 127}
128 128
129/** Mirrors `ra_toolchain::get_path_for_executable()` implementation */ 129/** Mirrors `toolchain::get_path_for_executable()` implementation */
130export const getPathForExecutable = memoize( 130export const getPathForExecutable = memoize(
131 // We apply caching to decrease file-system interactions 131 // We apply caching to decrease file-system interactions
132 (executableName: "cargo" | "rustc" | "rustup"): string => { 132 (executableName: "cargo" | "rustc" | "rustup"): string => {
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 970fedb37..49d2d1c6f 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -64,7 +64,8 @@ export async function sendRequestWithRetry<TParam, TRet>(
64 param: TParam, 64 param: TParam,
65 token?: vscode.CancellationToken, 65 token?: vscode.CancellationToken,
66): Promise<TRet> { 66): Promise<TRet> {
67 for (const delay of [2, 4, 6, 8, 10, null]) { 67 // The sequence is `10 * (2 ** (2 * n))` where n is 1, 2, 3...
68 for (const delay of [40, 160, 640, 2560, 10240, null]) {
68 try { 69 try {
69 return await (token 70 return await (token
70 ? client.sendRequest(reqType, param, token) 71 ? client.sendRequest(reqType, param, token)
@@ -84,8 +85,7 @@ export async function sendRequestWithRetry<TParam, TRet>(
84 log.warn("LSP request failed", { method: reqType.method, param, error }); 85 log.warn("LSP request failed", { method: reqType.method, param, error });
85 throw error; 86 throw error;
86 } 87 }
87 88 await sleep(delay);
88 await sleep(10 * (1 << delay));
89 } 89 }
90 } 90 }
91 throw 'unreachable'; 91 throw 'unreachable';