mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
SSR: Restrict to current selection if any
The selection is also used to avoid unnecessary work, but only to the file level. Further restricting unnecessary work is left for later.
This commit is contained in:
parent
5a8124273d
commit
cf55806257
10 changed files with 181 additions and 50 deletions
|
@ -190,6 +190,7 @@ export function ssr(ctx: Ctx): Cmd {
|
|||
if (!editor || !client) return;
|
||||
|
||||
const position = editor.selection.active;
|
||||
const selections = editor.selections;
|
||||
const textDocument = { uri: editor.document.uri.toString() };
|
||||
|
||||
const options: vscode.InputBoxOptions = {
|
||||
|
@ -198,7 +199,7 @@ export function ssr(ctx: Ctx): Cmd {
|
|||
validateInput: async (x: string) => {
|
||||
try {
|
||||
await client.sendRequest(ra.ssr, {
|
||||
query: x, parseOnly: true, textDocument, position,
|
||||
query: x, parseOnly: true, textDocument, position, selections,
|
||||
});
|
||||
} catch (e) {
|
||||
return e.toString();
|
||||
|
@ -215,7 +216,7 @@ export function ssr(ctx: Ctx): Cmd {
|
|||
cancellable: false,
|
||||
}, async (_progress, _token) => {
|
||||
const edit = await client.sendRequest(ra.ssr, {
|
||||
query: request, parseOnly: false, textDocument, position
|
||||
query: request, parseOnly: false, textDocument, position, selections,
|
||||
});
|
||||
|
||||
await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue