diff options
| author | Charles Pierce <cpierce.grad@gmail.com> | 2020-11-04 10:26:58 -0800 |
|---|---|---|
| committer | Charles Pierce <cpierce.grad@gmail.com> | 2020-11-04 10:26:58 -0800 |
| commit | d2bf2ebe15bd58e6d8937a5894a2363a1ca46b59 (patch) | |
| tree | a709268fe2f30267f5bd75181e576df8ef1497f0 /editors/code/src | |
| parent | 4e8401af4128ee533f82fe52cf4afb1ebc91603a (diff) | |
| download | rust-d2bf2ebe15bd58e6d8937a5894a2363a1ca46b59.tar.gz rust-d2bf2ebe15bd58e6d8937a5894a2363a1ca46b59.zip | |
Restore semantic token flickering workaround removed in #5697
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/client.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 1ba2352ee04..d032b45b71a 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -2,6 +2,7 @@ import * as lc from 'vscode-languageclient/node'; import * as vscode from 'vscode'; import * as ra from '../src/lsp_ext'; import * as Is from 'vscode-languageclient/lib/common/utils/is'; +import { DocumentSemanticsTokensSignature, DocumentSemanticsTokensEditsSignature, DocumentRangeSemanticTokensSignature } from 'vscode-languageclient/lib/common/semanticTokens'; import { assert } from './util'; function renderCommand(cmd: ra.CommandLink) { @@ -18,6 +19,13 @@ function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownStri return result; } +// Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 +async function semanticHighlightingWorkaround<R, F extends (...args: any[]) => vscode.ProviderResult<R>>(next: F, ...args: Parameters<F>): Promise<R> { + const res = await next(...args); + if (res == null) throw new Error('busy'); + return res; +} + export function createClient(serverPath: string, cwd: string): lc.LanguageClient { // '.' Is the fallback if no folder is open // TODO?: Workspace folders support Uri's (eg: file://test.txt). @@ -41,6 +49,15 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient diagnosticCollectionName: "rustc", traceOutputChannel, middleware: { + provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> { + return semanticHighlightingWorkaround(next, document, token); + }, + provideDocumentSemanticTokensEdits(document: vscode.TextDocument, previousResultId: string, token: vscode.CancellationToken, next: DocumentSemanticsTokensEditsSignature): vscode.ProviderResult<vscode.SemanticTokensEdits | vscode.SemanticTokens> { + return semanticHighlightingWorkaround(next, document, previousResultId, token); + }, + provideDocumentRangeSemanticTokens(document: vscode.TextDocument, range: vscode.Range, token: vscode.CancellationToken, next: DocumentRangeSemanticTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> { + return semanticHighlightingWorkaround(next, document, range, token); + }, async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( (result) => { |
