diff options
Diffstat (limited to 'editors/code/src/client.ts')
-rw-r--r-- | editors/code/src/client.ts | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 539e487ec..0771ca3b6 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -2,7 +2,6 @@ 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'; | ||
6 | import { assert } from './util'; | 5 | import { assert } from './util'; |
7 | import { WorkspaceEdit } from 'vscode'; | 6 | import { WorkspaceEdit } from 'vscode'; |
8 | 7 | ||
@@ -11,7 +10,7 @@ export interface Env { | |||
11 | } | 10 | } |
12 | 11 | ||
13 | function renderCommand(cmd: ra.CommandLink) { | 12 | function renderCommand(cmd: ra.CommandLink) { |
14 | return `[${cmd.title}](command:${cmd.command}?${encodeURIComponent(JSON.stringify(cmd.arguments))} '${cmd.tooltip!}')`; | 13 | return `[${cmd.title}](command:${cmd.command}?${encodeURIComponent(JSON.stringify(cmd.arguments))} '${cmd.tooltip}')`; |
15 | } | 14 | } |
16 | 15 | ||
17 | function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownString { | 16 | function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownString { |
@@ -24,13 +23,6 @@ function renderHoverActions(actions: ra.CommandLinkGroup[]): vscode.MarkdownStri | |||
24 | return result; | 23 | return result; |
25 | } | 24 | } |
26 | 25 | ||
27 | // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 | ||
28 | async function semanticHighlightingWorkaround<R, F extends (...args: any[]) => vscode.ProviderResult<R>>(next: F, ...args: Parameters<F>): Promise<R> { | ||
29 | const res = await next(...args); | ||
30 | if (res == null) throw new Error('busy'); | ||
31 | return res; | ||
32 | } | ||
33 | |||
34 | export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc.LanguageClient { | 26 | export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc.LanguageClient { |
35 | // '.' Is the fallback if no folder is open | 27 | // '.' Is the fallback if no folder is open |
36 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). | 28 | // TODO?: Workspace folders support Uri's (eg: file://test.txt). |
@@ -57,15 +49,6 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc | |||
57 | diagnosticCollectionName: "rustc", | 49 | diagnosticCollectionName: "rustc", |
58 | traceOutputChannel, | 50 | traceOutputChannel, |
59 | middleware: { | 51 | middleware: { |
60 | provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> { | ||
61 | return semanticHighlightingWorkaround(next, document, token); | ||
62 | }, | ||
63 | provideDocumentSemanticTokensEdits(document: vscode.TextDocument, previousResultId: string, token: vscode.CancellationToken, next: DocumentSemanticsTokensEditsSignature): vscode.ProviderResult<vscode.SemanticTokensEdits | vscode.SemanticTokens> { | ||
64 | return semanticHighlightingWorkaround(next, document, previousResultId, token); | ||
65 | }, | ||
66 | provideDocumentRangeSemanticTokens(document: vscode.TextDocument, range: vscode.Range, token: vscode.CancellationToken, next: DocumentRangeSemanticTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> { | ||
67 | return semanticHighlightingWorkaround(next, document, range, token); | ||
68 | }, | ||
69 | async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { | 52 | async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { |
70 | return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( | 53 | return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( |
71 | (result) => { | 54 | (result) => { |
@@ -79,7 +62,7 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc | |||
79 | return hover; | 62 | return hover; |
80 | }, | 63 | }, |
81 | (error) => { | 64 | (error) => { |
82 | client.handleFailedRequest(lc.HoverRequest.type, error, null); | 65 | client.handleFailedRequest(lc.HoverRequest.type, token, error, null); |
83 | return Promise.resolve(null); | 66 | return Promise.resolve(null); |
84 | }); | 67 | }); |
85 | }, | 68 | }, |
@@ -138,7 +121,7 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc | |||
138 | command: "rust-analyzer.applyActionGroup", | 121 | command: "rust-analyzer.applyActionGroup", |
139 | title: "", | 122 | title: "", |
140 | arguments: [items.map((item) => { | 123 | arguments: [items.map((item) => { |
141 | return { label: item.title, arguments: item.command!!.arguments!![0] }; | 124 | return { label: item.title, arguments: item.command!.arguments![0] }; |
142 | })], | 125 | })], |
143 | }; | 126 | }; |
144 | 127 | ||