diff options
Diffstat (limited to 'editors/code/src/commands/on_enter.ts')
-rw-r--r-- | editors/code/src/commands/on_enter.ts | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts deleted file mode 100644 index a7871c31e..000000000 --- a/editors/code/src/commands/on_enter.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | import * as ra from '../rust-analyzer-api'; | ||
3 | |||
4 | import { Cmd, Ctx } from '../ctx'; | ||
5 | import { applySnippetWorkspaceEdit } from '.'; | ||
6 | |||
7 | async function handleKeypress(ctx: Ctx) { | ||
8 | const editor = ctx.activeRustEditor; | ||
9 | const client = ctx.client; | ||
10 | |||
11 | if (!editor || !client) return false; | ||
12 | |||
13 | const change = await client.sendRequest(ra.onEnter, { | ||
14 | textDocument: { uri: editor.document.uri.toString() }, | ||
15 | position: client.code2ProtocolConverter.asPosition( | ||
16 | editor.selection.active, | ||
17 | ), | ||
18 | }).catch(_error => { | ||
19 | // client.logFailedRequest(OnEnterRequest.type, error); | ||
20 | return null; | ||
21 | }); | ||
22 | if (!change) return false; | ||
23 | |||
24 | const workspaceEdit = client.protocol2CodeConverter.asWorkspaceEdit(change); | ||
25 | await applySnippetWorkspaceEdit(workspaceEdit); | ||
26 | return true; | ||
27 | } | ||
28 | |||
29 | export function onEnter(ctx: Ctx): Cmd { | ||
30 | return async () => { | ||
31 | if (await handleKeypress(ctx)) return; | ||
32 | |||
33 | await vscode.commands.executeCommand('default:type', { text: '\n' }); | ||
34 | }; | ||
35 | } | ||