diff options
author | Aleksey Kladov <[email protected]> | 2018-08-23 20:14:51 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-23 20:14:51 +0100 |
commit | 8ad586a44e2214a11c4e7d27e0d3c2d73e43f39f (patch) | |
tree | 70c553dd0231189acf0695b63688f21fb94867dc /code/src/extension.ts | |
parent | 18918769baf49acc4067eabdc0c3a0a98224d23f (diff) |
JoinLines frontend
Diffstat (limited to 'code/src/extension.ts')
-rw-r--r-- | code/src/extension.ts | 18 |
1 files changed, 18 insertions, 0 deletions
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) { | |||
51 | return new vscode.Selection(anchor, active) | 51 | return new vscode.Selection(anchor, active) |
52 | }) | 52 | }) |
53 | }) | 53 | }) |
54 | registerCommand('libsyntax-rust.joinLines', async () => { | ||
55 | let editor = vscode.window.activeTextEditor | ||
56 | if (editor == null || editor.document.languageId != "rust") return | ||
57 | let request: JoinLinesParams = { | ||
58 | textDocument: { uri: editor.document.uri.toString() }, | ||
59 | range: client.code2ProtocolConverter.asRange(editor.selection), | ||
60 | } | ||
61 | let response = await client.sendRequest<lc.TextEdit[]>("m/joinLines", request) | ||
62 | let edits = client.protocol2CodeConverter.asTextEdits(response) | ||
63 | let wsEdit = new vscode.WorkspaceEdit() | ||
64 | wsEdit.set(editor.document.uri, edits) | ||
65 | return vscode.workspace.applyEdit(wsEdit) | ||
66 | }) | ||
54 | registerCommand('libsyntax-rust.parentModule', async () => { | 67 | registerCommand('libsyntax-rust.parentModule', async () => { |
55 | let editor = vscode.window.activeTextEditor | 68 | let editor = vscode.window.activeTextEditor |
56 | if (editor == null || editor.document.languageId != "rust") return | 69 | if (editor == null || editor.document.languageId != "rust") return |
@@ -237,6 +250,11 @@ interface FindMatchingBraceParams { | |||
237 | offsets: lc.Position[]; | 250 | offsets: lc.Position[]; |
238 | } | 251 | } |
239 | 252 | ||
253 | interface JoinLinesParams { | ||
254 | textDocument: lc.TextDocumentIdentifier; | ||
255 | range: lc.Range; | ||
256 | } | ||
257 | |||
240 | interface PublishDecorationsParams { | 258 | interface PublishDecorationsParams { |
241 | uri: string, | 259 | uri: string, |
242 | decorations: Decoration[], | 260 | decorations: Decoration[], |