diff options
Diffstat (limited to 'editors/code/src/commands/ssr.ts')
-rw-r--r-- | editors/code/src/commands/ssr.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/editors/code/src/commands/ssr.ts b/editors/code/src/commands/ssr.ts new file mode 100644 index 000000000..6287bf47b --- /dev/null +++ b/editors/code/src/commands/ssr.ts | |||
@@ -0,0 +1,36 @@ | |||
1 | import { Ctx, Cmd } from '../ctx'; | ||
2 | import { applySourceChange, SourceChange } from '../source_change'; | ||
3 | import * as vscode from 'vscode'; | ||
4 | |||
5 | export function ssr(ctx: Ctx): Cmd { | ||
6 | return async () => { | ||
7 | const client = ctx.client; | ||
8 | if (!client) return; | ||
9 | |||
10 | const options: vscode.InputBoxOptions = { | ||
11 | placeHolder: "foo($a:expr, $b:expr) ==>> bar($a, foo($b))", | ||
12 | prompt: "Enter request", | ||
13 | validateInput: (x: string) => { | ||
14 | if (x.includes('==>>')) { | ||
15 | return null; | ||
16 | } | ||
17 | return "Enter request: pattern ==>> template" | ||
18 | } | ||
19 | } | ||
20 | const request = await vscode.window.showInputBox(options); | ||
21 | |||
22 | if (!request) return; | ||
23 | |||
24 | const ssrRequest: SsrRequest = { arg: request }; | ||
25 | const change = await client.sendRequest<SourceChange>( | ||
26 | 'rust-analyzer/ssr', | ||
27 | ssrRequest, | ||
28 | ); | ||
29 | |||
30 | await applySourceChange(ctx, change); | ||
31 | }; | ||
32 | } | ||
33 | |||
34 | interface SsrRequest { | ||
35 | arg: string; | ||
36 | } | ||