diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/package.json | 5 | ||||
-rw-r--r-- | code/src/extension.ts | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/code/package.json b/code/package.json index fd3b8e423..042821b1c 100644 --- a/code/package.json +++ b/code/package.json | |||
@@ -41,6 +41,11 @@ | |||
41 | "command": "libsyntax-rust.matchingBrace", | 41 | "command": "libsyntax-rust.matchingBrace", |
42 | "key": "ctrl+shift+m", | 42 | "key": "ctrl+shift+m", |
43 | "title": "Rust Matching Brace" | 43 | "title": "Rust Matching Brace" |
44 | }, | ||
45 | { | ||
46 | "command": "libsyntax-rust.parentModule", | ||
47 | "key": "ctrl+u", | ||
48 | "title": "Rust Parent Module" | ||
44 | } | 49 | } |
45 | ], | 50 | ], |
46 | "keybindings": [ | 51 | "keybindings": [ |
diff --git a/code/src/extension.ts b/code/src/extension.ts index 084a9d769..fb6841fa0 100644 --- a/code/src/extension.ts +++ b/code/src/extension.ts | |||
@@ -51,6 +51,22 @@ 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.parentModule', async () => { | ||
55 | let editor = vscode.window.activeTextEditor | ||
56 | if (editor == null || editor.document.languageId != "rust") return | ||
57 | let request: lc.TextDocumentIdentifier = { | ||
58 | uri: editor.document.uri.toString() | ||
59 | } | ||
60 | let response = await client.sendRequest<lc.TextDocumentIdentifier>("m/parentModule", request) | ||
61 | let loc: lc.Location = response[0] | ||
62 | if (loc == null) return | ||
63 | let uri = client.protocol2CodeConverter.asUri(loc.uri) | ||
64 | let range = client.protocol2CodeConverter.asRange(loc.range) | ||
65 | |||
66 | let doc = await vscode.workspace.openTextDocument(uri) | ||
67 | let e = await vscode.window.showTextDocument(doc) | ||
68 | e.revealRange(range, vscode.TextEditorRevealType.InCenter) | ||
69 | }) | ||
54 | 70 | ||
55 | dispose(vscode.workspace.registerTextDocumentContentProvider( | 71 | dispose(vscode.workspace.registerTextDocumentContentProvider( |
56 | 'libsyntax-rust', | 72 | 'libsyntax-rust', |