From 8ad586a44e2214a11c4e7d27e0d3c2d73e43f39f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 23 Aug 2018 22:14:51 +0300 Subject: JoinLines frontend --- code/package.json | 9 +++++++++ code/src/extension.ts | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'code') diff --git a/code/package.json b/code/package.json index 35367edb6..20a6ceee7 100644 --- a/code/package.json +++ b/code/package.json @@ -44,6 +44,10 @@ { "command": "libsyntax-rust.parentModule", "title": "Rust Parent Module" + }, + { + "command": "libsyntax-rust.joinLines", + "title": "Rust Join Lines" } ], "keybindings": [ @@ -61,6 +65,11 @@ "command": "libsyntax-rust.extendSelection", "key": "ctrl+w", "when": "editorTextFocus && editorLangId == rust" + }, + { + "command": "libsyntax-rust.joinLines", + "key": "ctrl+shift+j", + "when": "editorTextFocus && editorLangId == rust" } ], "problemMatchers": [ diff --git a/code/src/extension.ts b/code/src/extension.ts index fb6841fa0..134459f30 100644 --- a/code/src/extension.ts +++ b/code/src/extension.ts @@ -51,6 +51,19 @@ export function activate(context: vscode.ExtensionContext) { return new vscode.Selection(anchor, active) }) }) + registerCommand('libsyntax-rust.joinLines', async () => { + let editor = vscode.window.activeTextEditor + if (editor == null || editor.document.languageId != "rust") return + let request: JoinLinesParams = { + textDocument: { uri: editor.document.uri.toString() }, + range: client.code2ProtocolConverter.asRange(editor.selection), + } + let response = await client.sendRequest("m/joinLines", request) + let edits = client.protocol2CodeConverter.asTextEdits(response) + let wsEdit = new vscode.WorkspaceEdit() + wsEdit.set(editor.document.uri, edits) + return vscode.workspace.applyEdit(wsEdit) + }) registerCommand('libsyntax-rust.parentModule', async () => { let editor = vscode.window.activeTextEditor if (editor == null || editor.document.languageId != "rust") return @@ -237,6 +250,11 @@ interface FindMatchingBraceParams { offsets: lc.Position[]; } +interface JoinLinesParams { + textDocument: lc.TextDocumentIdentifier; + range: lc.Range; +} + interface PublishDecorationsParams { uri: string, decorations: Decoration[], -- cgit v1.2.3