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.ts25
1 files changed, 10 insertions, 15 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 4170b9ccb..3729a71de 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -125,12 +125,11 @@ export function joinLines(ctx: Ctx): Cmd {
125 ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)), 125 ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)),
126 textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), 126 textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
127 }); 127 });
128 editor.edit((builder) => { 128 await editor.edit((builder) => {
129 client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => { 129 client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => {
130 builder.replace(edit.range, edit.newText); 130 builder.replace(edit.range, edit.newText);
131 }); 131 });
132 }) 132 });
133 .then(() => { }, console.error);
134 }; 133 };
135} 134}
136 135
@@ -237,7 +236,7 @@ export function ssr(ctx: Ctx): Cmd {
237 const request = await vscode.window.showInputBox(options); 236 const request = await vscode.window.showInputBox(options);
238 if (!request) return; 237 if (!request) return;
239 238
240 vscode.window.withProgress({ 239 await vscode.window.withProgress({
241 location: vscode.ProgressLocation.Notification, 240 location: vscode.ProgressLocation.Notification,
242 title: "Structured search replace in progress...", 241 title: "Structured search replace in progress...",
243 cancellable: false, 242 cancellable: false,
@@ -247,8 +246,7 @@ export function ssr(ctx: Ctx): Cmd {
247 }); 246 });
248 247
249 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); 248 await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
250 }) 249 });
251 .then(() => { }, console.error);
252 }; 250 };
253} 251}
254 252
@@ -459,16 +457,15 @@ export function reloadWorkspace(ctx: Ctx): Cmd {
459} 457}
460 458
461export function showReferences(ctx: Ctx): Cmd { 459export function showReferences(ctx: Ctx): Cmd {
462 return (uri: string, position: lc.Position, locations: lc.Location[]) => { 460 return async (uri: string, position: lc.Position, locations: lc.Location[]) => {
463 const client = ctx.client; 461 const client = ctx.client;
464 if (client) { 462 if (client) {
465 vscode.commands.executeCommand( 463 await vscode.commands.executeCommand(
466 'editor.action.showReferences', 464 'editor.action.showReferences',
467 vscode.Uri.parse(uri), 465 vscode.Uri.parse(uri),
468 client.protocol2CodeConverter.asPosition(position), 466 client.protocol2CodeConverter.asPosition(position),
469 locations.map(client.protocol2CodeConverter.asLocation), 467 locations.map(client.protocol2CodeConverter.asLocation),
470 ) 468 );
471 .then(() => { }, console.error);
472 } 469 }
473 }; 470 };
474} 471}
@@ -477,11 +474,10 @@ export function applyActionGroup(_ctx: Ctx): Cmd {
477 return async (actions: { label: string; arguments: lc.CodeAction }[]) => { 474 return async (actions: { label: string; arguments: lc.CodeAction }[]) => {
478 const selectedAction = await vscode.window.showQuickPick(actions); 475 const selectedAction = await vscode.window.showQuickPick(actions);
479 if (!selectedAction) return; 476 if (!selectedAction) return;
480 vscode.commands.executeCommand( 477 await vscode.commands.executeCommand(
481 'rust-analyzer.resolveCodeAction', 478 'rust-analyzer.resolveCodeAction',
482 selectedAction.arguments, 479 selectedAction.arguments,
483 ) 480 );
484 .then(() => { }, console.error);
485 }; 481 };
486} 482}
487 483
@@ -514,8 +510,7 @@ export function openDocs(ctx: Ctx): Cmd {
514 const doclink = await client.sendRequest(ra.openDocs, { position, textDocument }); 510 const doclink = await client.sendRequest(ra.openDocs, { position, textDocument });
515 511
516 if (doclink != null) { 512 if (doclink != null) {
517 vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink)) 513 await vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink));
518 .then(() => { }, console.error);
519 } 514 }
520 }; 515 };
521 516