From 3975952601888d9f77e466c12e8e389748984b33 Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Wed, 22 Jul 2020 15:00:28 +1000 Subject: SSR: Pass current file position through to SSR code. In a subsequent commit, it will be used for resolving paths. --- editors/code/src/commands.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'editors/code/src/commands.ts') diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 1f3a7cf7e..3ae995705 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -185,15 +185,21 @@ export function parentModule(ctx: Ctx): Cmd { export function ssr(ctx: Ctx): Cmd { return async () => { + const editor = vscode.window.activeTextEditor; const client = ctx.client; - if (!client) return; + if (!editor || !client) return; + + const position = editor.selection.active; + let textDocument = { uri: editor.document.uri.toString() }; const options: vscode.InputBoxOptions = { value: "() ==>> ()", prompt: "Enter request, for example 'Foo($a) ==> Foo::new($a)' ", validateInput: async (x: string) => { try { - await client.sendRequest(ra.ssr, { query: x, parseOnly: true }); + await client.sendRequest(ra.ssr, { + query: x, parseOnly: true, textDocument, position, + }); } catch (e) { return e.toString(); } @@ -208,7 +214,9 @@ export function ssr(ctx: Ctx): Cmd { title: "Structured search replace in progress...", cancellable: false, }, async (_progress, _token) => { - const edit = await client.sendRequest(ra.ssr, { query: request, parseOnly: false }); + const edit = await client.sendRequest(ra.ssr, { + query: request, parseOnly: false, textDocument, position + }); await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit)); }); -- cgit v1.2.3