mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Less rust-analyzer specific onEnter
This commit is contained in:
parent
e4f91bfa57
commit
76e170c3d0
11 changed files with 105 additions and 55 deletions
|
@ -3,7 +3,7 @@ import * as lc from 'vscode-languageclient';
|
|||
import * as ra from './rust-analyzer-api';
|
||||
|
||||
import { Ctx, Cmd } from './ctx';
|
||||
import { applySnippetWorkspaceEdit } from './snippets';
|
||||
import { applySnippetWorkspaceEdit, applySnippetTextEdits } from './snippets';
|
||||
import { spawnSync } from 'child_process';
|
||||
import { RunnableQuickPick, selectRunnable, createTask } from './run';
|
||||
import { AstInspector } from './ast_inspector';
|
||||
|
@ -102,7 +102,7 @@ export function onEnter(ctx: Ctx): Cmd {
|
|||
|
||||
if (!editor || !client) return false;
|
||||
|
||||
const change = await client.sendRequest(ra.onEnter, {
|
||||
const lcEdits = await client.sendRequest(ra.onEnter, {
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
position: client.code2ProtocolConverter.asPosition(
|
||||
editor.selection.active,
|
||||
|
@ -111,10 +111,10 @@ export function onEnter(ctx: Ctx): Cmd {
|
|||
// client.logFailedRequest(OnEnterRequest.type, error);
|
||||
return null;
|
||||
});
|
||||
if (!change) return false;
|
||||
if (!lcEdits) return false;
|
||||
|
||||
const workspaceEdit = client.protocol2CodeConverter.asWorkspaceEdit(change);
|
||||
await applySnippetWorkspaceEdit(workspaceEdit);
|
||||
const edits = client.protocol2CodeConverter.asTextEdits(lcEdits);
|
||||
await applySnippetTextEdits(editor, edits);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue