diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/code/src/commands.ts | 19 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 5 |
2 files changed, 16 insertions, 8 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index e9581a9b5..1a90f1b7d 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -21,7 +21,12 @@ export function analyzerStatus(ctx: Ctx): Cmd { | |||
21 | provideTextDocumentContent(_uri: vscode.Uri): vscode.ProviderResult<string> { | 21 | provideTextDocumentContent(_uri: vscode.Uri): vscode.ProviderResult<string> { |
22 | if (!vscode.window.activeTextEditor) return ''; | 22 | if (!vscode.window.activeTextEditor) return ''; |
23 | 23 | ||
24 | return ctx.client.sendRequest(ra.analyzerStatus); | 24 | const params: ra.AnalyzerStatusParams = {}; |
25 | const doc = ctx.activeRustEditor?.document; | ||
26 | if (doc != null) { | ||
27 | params.textDocument = ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(doc); | ||
28 | } | ||
29 | return ctx.client.sendRequest(ra.analyzerStatus, params); | ||
25 | } | 30 | } |
26 | 31 | ||
27 | get onDidChange(): vscode.Event<vscode.Uri> { | 32 | get onDidChange(): vscode.Event<vscode.Uri> { |
@@ -94,7 +99,7 @@ export function matchingBrace(ctx: Ctx): Cmd { | |||
94 | if (!editor || !client) return; | 99 | if (!editor || !client) return; |
95 | 100 | ||
96 | const response = await client.sendRequest(ra.matchingBrace, { | 101 | const response = await client.sendRequest(ra.matchingBrace, { |
97 | textDocument: { uri: editor.document.uri.toString() }, | 102 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), |
98 | positions: editor.selections.map(s => | 103 | positions: editor.selections.map(s => |
99 | client.code2ProtocolConverter.asPosition(s.active), | 104 | client.code2ProtocolConverter.asPosition(s.active), |
100 | ), | 105 | ), |
@@ -118,7 +123,7 @@ export function joinLines(ctx: Ctx): Cmd { | |||
118 | 123 | ||
119 | const items: lc.TextEdit[] = await client.sendRequest(ra.joinLines, { | 124 | const items: lc.TextEdit[] = await client.sendRequest(ra.joinLines, { |
120 | ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)), | 125 | ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)), |
121 | textDocument: { uri: editor.document.uri.toString() }, | 126 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), |
122 | }); | 127 | }); |
123 | editor.edit((builder) => { | 128 | editor.edit((builder) => { |
124 | client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => { | 129 | client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => { |
@@ -136,7 +141,7 @@ export function onEnter(ctx: Ctx): Cmd { | |||
136 | if (!editor || !client) return false; | 141 | if (!editor || !client) return false; |
137 | 142 | ||
138 | const lcEdits = await client.sendRequest(ra.onEnter, { | 143 | const lcEdits = await client.sendRequest(ra.onEnter, { |
139 | textDocument: { uri: editor.document.uri.toString() }, | 144 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), |
140 | position: client.code2ProtocolConverter.asPosition( | 145 | position: client.code2ProtocolConverter.asPosition( |
141 | editor.selection.active, | 146 | editor.selection.active, |
142 | ), | 147 | ), |
@@ -165,7 +170,7 @@ export function parentModule(ctx: Ctx): Cmd { | |||
165 | if (!editor || !client) return; | 170 | if (!editor || !client) return; |
166 | 171 | ||
167 | const response = await client.sendRequest(ra.parentModule, { | 172 | const response = await client.sendRequest(ra.parentModule, { |
168 | textDocument: { uri: editor.document.uri.toString() }, | 173 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), |
169 | position: client.code2ProtocolConverter.asPosition( | 174 | position: client.code2ProtocolConverter.asPosition( |
170 | editor.selection.active, | 175 | editor.selection.active, |
171 | ), | 176 | ), |
@@ -191,7 +196,7 @@ export function ssr(ctx: Ctx): Cmd { | |||
191 | 196 | ||
192 | const position = editor.selection.active; | 197 | const position = editor.selection.active; |
193 | const selections = editor.selections; | 198 | const selections = editor.selections; |
194 | const textDocument = { uri: editor.document.uri.toString() }; | 199 | const textDocument = ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document); |
195 | 200 | ||
196 | const options: vscode.InputBoxOptions = { | 201 | const options: vscode.InputBoxOptions = { |
197 | value: "() ==>> ()", | 202 | value: "() ==>> ()", |
@@ -339,7 +344,7 @@ export function expandMacro(ctx: Ctx): Cmd { | |||
339 | const position = editor.selection.active; | 344 | const position = editor.selection.active; |
340 | 345 | ||
341 | const expanded = await client.sendRequest(ra.expandMacro, { | 346 | const expanded = await client.sendRequest(ra.expandMacro, { |
342 | textDocument: { uri: editor.document.uri.toString() }, | 347 | textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), |
343 | position, | 348 | position, |
344 | }); | 349 | }); |
345 | 350 | ||
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index d167041c4..eb422d3e7 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -4,7 +4,10 @@ | |||
4 | 4 | ||
5 | import * as lc from "vscode-languageclient"; | 5 | import * as lc from "vscode-languageclient"; |
6 | 6 | ||
7 | export const analyzerStatus = new lc.RequestType0<string, void>("rust-analyzer/analyzerStatus"); | 7 | export interface AnalyzerStatusParams { |
8 | textDocument?: lc.TextDocumentIdentifier; | ||
9 | } | ||
10 | export const analyzerStatus = new lc.RequestType<AnalyzerStatusParams, string, void>("rust-analyzer/analyzerStatus"); | ||
8 | export const memoryUsage = new lc.RequestType0<string, void>("rust-analyzer/memoryUsage"); | 11 | export const memoryUsage = new lc.RequestType0<string, void>("rust-analyzer/memoryUsage"); |
9 | 12 | ||
10 | export type Status = "loading" | "ready" | "invalid" | "needsReload"; | 13 | export type Status = "loading" | "ready" | "invalid" | "needsReload"; |