aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-23 20:14:51 +0100
committerAleksey Kladov <[email protected]>2018-08-23 20:14:51 +0100
commit8ad586a44e2214a11c4e7d27e0d3c2d73e43f39f (patch)
tree70c553dd0231189acf0695b63688f21fb94867dc /code
parent18918769baf49acc4067eabdc0c3a0a98224d23f (diff)
JoinLines frontend
Diffstat (limited to 'code')
-rw-r--r--code/package.json9
-rw-r--r--code/src/extension.ts18
2 files changed, 27 insertions, 0 deletions
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 @@
44 { 44 {
45 "command": "libsyntax-rust.parentModule", 45 "command": "libsyntax-rust.parentModule",
46 "title": "Rust Parent Module" 46 "title": "Rust Parent Module"
47 },
48 {
49 "command": "libsyntax-rust.joinLines",
50 "title": "Rust Join Lines"
47 } 51 }
48 ], 52 ],
49 "keybindings": [ 53 "keybindings": [
@@ -61,6 +65,11 @@
61 "command": "libsyntax-rust.extendSelection", 65 "command": "libsyntax-rust.extendSelection",
62 "key": "ctrl+w", 66 "key": "ctrl+w",
63 "when": "editorTextFocus && editorLangId == rust" 67 "when": "editorTextFocus && editorLangId == rust"
68 },
69 {
70 "command": "libsyntax-rust.joinLines",
71 "key": "ctrl+shift+j",
72 "when": "editorTextFocus && editorLangId == rust"
64 } 73 }
65 ], 74 ],
66 "problemMatchers": [ 75 "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) {
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
253interface JoinLinesParams {
254 textDocument: lc.TextDocumentIdentifier;
255 range: lc.Range;
256}
257
240interface PublishDecorationsParams { 258interface PublishDecorationsParams {
241 uri: string, 259 uri: string,
242 decorations: Decoration[], 260 decorations: Decoration[],