diff options
author | Charles Pierce <[email protected]> | 2020-11-04 18:26:58 +0000 |
---|---|---|
committer | Charles Pierce <[email protected]> | 2020-11-04 18:26:58 +0000 |
commit | d2bf2ebe15bd58e6d8937a5894a2363a1ca46b59 (patch) | |
tree | a709268fe2f30267f5bd75181e576df8ef1497f0 /editors/code/src | |
parent | 4e8401af4128ee533f82fe52cf4afb1ebc91603a (diff) |
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 1ba2352ee..d032b45b7 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -2,6 +2,7 @@ import * as lc from 'vscode-languageclient/node'; | |||
2 | import * as vscode from 'vscode'; | 2 | import * as vscode from 'vscode'; |
3 | import * as ra from '../src/lsp_ext'; | 3 | import * as ra from '../src/lsp_ext'; |
4 | import * as Is from 'vscode-languageclient/lib/common/utils/is'; | 4 | import * as Is from 'vscode-languageclient/lib/common/utils/is'; |
5 | import { DocumentSemanticsTokensSignature, DocumentSemanticsTokensEditsSignature, DocumentRangeSemanticTokensSignature } from 'vscode-languageclient/lib/common/semanticTokens'; | ||
5 | import { assert } from './util'; | 6 | import { assert } from './util'; |
6 | 7 | ||
7 | function renderCommand(cmd: ra.CommandLink) { | 8 | function renderCommand(cmd: ra.CommandLink) { |
@@ -18,6 +19,13 @@ function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownStri | |||
18 | return result; | 19 | return result; |
19 | } | 20 | } |
20 | 21 | ||
22 | // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 | ||
23 | async function semanticHighlightingWorkaround<R, F extends (...args: any[]) => vscode.ProviderResult<R>>(next: F, ...args: Parameters<F>): Promise<R> { | ||
24 | const res = await next(...args); | ||
25 | if (res == null) throw new Error('busy'); | ||
26 | return res; | ||
27 | } | ||
28 | |||
21 | export function createClient(serverPath: string, cwd: string): lc.LanguageClient { | 29 | export function createClient(serverPath: string, cwd: string): lc.LanguageClient { |
22 | // '.' Is the fallback if no folder is open | 30 | // '.' Is the fallback if no folder is open |
23 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). | 31 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). |
@@ -41,6 +49,15 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient | |||
41 | diagnosticCollectionName: "rustc", | 49 | diagnosticCollectionName: "rustc", |
42 | traceOutputChannel, | 50 | traceOutputChannel, |
43 | middleware: { | 51 | middleware: { |
52 | provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> { | ||
53 | return semanticHighlightingWorkaround(next, document, token); | ||
54 | }, | ||
55 | provideDocumentSemanticTokensEdits(document: vscode.TextDocument, previousResultId: string, token: vscode.CancellationToken, next: DocumentSemanticsTokensEditsSignature): vscode.ProviderResult<vscode.SemanticTokensEdits | vscode.SemanticTokens> { | ||
56 | return semanticHighlightingWorkaround(next, document, previousResultId, token); | ||
57 | }, | ||
58 | provideDocumentRangeSemanticTokens(document: vscode.TextDocument, range: vscode.Range, token: vscode.CancellationToken, next: DocumentRangeSemanticTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> { | ||
59 | return semanticHighlightingWorkaround(next, document, range, token); | ||
60 | }, | ||
44 | async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { | 61 | async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { |
45 | return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( | 62 | return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( |
46 | (result) => { | 63 | (result) => { |