aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/on_enter.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands/on_enter.ts')
-rw-r--r--editors/code/src/commands/on_enter.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts
index 8324060e8..6f61883cd 100644
--- a/editors/code/src/commands/on_enter.ts
+++ b/editors/code/src/commands/on_enter.ts
@@ -6,15 +6,17 @@ import { Cmd, Ctx } from '../ctx';
6export function onEnter(ctx: Ctx): Cmd { 6export function onEnter(ctx: Ctx): Cmd {
7 return async (event: { text: string }) => { 7 return async (event: { text: string }) => {
8 const editor = ctx.activeRustEditor; 8 const editor = ctx.activeRustEditor;
9 const client = ctx.client;
9 if (!editor || event.text !== '\n') return false; 10 if (!editor || event.text !== '\n') return false;
11 if (!client) return false;
10 12
11 const request: lc.TextDocumentPositionParams = { 13 const request: lc.TextDocumentPositionParams = {
12 textDocument: { uri: editor.document.uri.toString() }, 14 textDocument: { uri: editor.document.uri.toString() },
13 position: ctx.client.code2ProtocolConverter.asPosition( 15 position: client.code2ProtocolConverter.asPosition(
14 editor.selection.active, 16 editor.selection.active,
15 ), 17 ),
16 }; 18 };
17 const change = await ctx.client.sendRequest<undefined | SourceChange>( 19 const change = await client.sendRequest<undefined | SourceChange>(
18 'rust-analyzer/onEnter', 20 'rust-analyzer/onEnter',
19 request, 21 request,
20 ); 22 );