aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands.ts')
-rw-r--r--editors/code/src/commands.ts19
1 files changed, 12 insertions, 7 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