Files
rust/editors/code/src/commands/ssr.ts

31 lines
911 B
TypeScript
Raw Normal View History

import * as vscode from 'vscode';
import * as ra from "../rust-analyzer-api";
import { Ctx, Cmd } from '../ctx';
import { applySourceChange } from '../source_change';
export function ssr(ctx: Ctx): Cmd {
return async () => {
const client = ctx.client;
if (!client) return;
const options: vscode.InputBoxOptions = {
placeHolder: "foo($a:expr, $b:expr) ==>> bar($a, foo($b))",
prompt: "Enter request",
validateInput: (x: string) => {
if (x.includes('==>>')) {
return null;
}
2020-02-17 22:09:44 +02:00
return "Enter request: pattern ==>> template";
}
2020-02-17 22:09:44 +02:00
};
const request = await vscode.window.showInputBox(options);
if (!request) return;
const change = await client.sendRequest(ra.ssr, { arg: request },);
await applySourceChange(ctx, change);
};
}