diff options
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/index.ts | 14 | ||||
-rw-r--r-- | editors/code/src/commands/ssr.ts | 6 |
2 files changed, 7 insertions, 13 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index e5ed77e32..abb53a248 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -41,15 +41,11 @@ export function applySourceChange(ctx: Ctx): Cmd { | |||
41 | }; | 41 | }; |
42 | } | 42 | } |
43 | 43 | ||
44 | export function selectAndApplySourceChange(ctx: Ctx): Cmd { | 44 | export function applyActionGroup(_ctx: Ctx): Cmd { |
45 | return async (changes: ra.SourceChange[]) => { | 45 | return async (actions: { label: string; edit: vscode.WorkspaceEdit }[]) => { |
46 | if (changes.length === 1) { | 46 | const selectedAction = await vscode.window.showQuickPick(actions); |
47 | await sourceChange.applySourceChange(ctx, changes[0]); | 47 | if (!selectedAction) return; |
48 | } else if (changes.length > 0) { | 48 | await applySnippetWorkspaceEdit(selectedAction.edit); |
49 | const selectedChange = await vscode.window.showQuickPick(changes); | ||
50 | if (!selectedChange) return; | ||
51 | await sourceChange.applySourceChange(ctx, selectedChange); | ||
52 | } | ||
53 | }; | 49 | }; |
54 | } | 50 | } |
55 | 51 | ||
diff --git a/editors/code/src/commands/ssr.ts b/editors/code/src/commands/ssr.ts index 4ef8cdf04..5d40a64d2 100644 --- a/editors/code/src/commands/ssr.ts +++ b/editors/code/src/commands/ssr.ts | |||
@@ -2,7 +2,6 @@ import * as vscode from 'vscode'; | |||
2 | import * as ra from "../rust-analyzer-api"; | 2 | import * as ra from "../rust-analyzer-api"; |
3 | 3 | ||
4 | import { Ctx, Cmd } from '../ctx'; | 4 | import { Ctx, Cmd } from '../ctx'; |
5 | import { applySourceChange } from '../source_change'; | ||
6 | 5 | ||
7 | export function ssr(ctx: Ctx): Cmd { | 6 | export function ssr(ctx: Ctx): Cmd { |
8 | return async () => { | 7 | return async () => { |
@@ -22,11 +21,10 @@ export function ssr(ctx: Ctx): Cmd { | |||
22 | } | 21 | } |
23 | }; | 22 | }; |
24 | const request = await vscode.window.showInputBox(options); | 23 | const request = await vscode.window.showInputBox(options); |
25 | |||
26 | if (!request) return; | 24 | if (!request) return; |
27 | 25 | ||
28 | const change = await client.sendRequest(ra.ssr, { query: request, parseOnly: false }); | 26 | const edit = await client.sendRequest(ra.ssr, { query: request, parseOnly: false }); |
29 | 27 | ||
30 | await applySourceChange(ctx, change); | 28 | await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); |
31 | }; | 29 | }; |
32 | } | 30 | } |