aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-12 08:38:24 +0100
committerGitHub <[email protected]>2020-10-12 08:38:24 +0100
commit518f6d772482c7c58e59081f340947087a9b4800 (patch)
treed904f1b98cad63944b4c405238d8b3938a9debb9 /editors/code/src/commands.ts
parentd5fcedb38eec33e2eb12ed550a9b90f6950855fe (diff)
parent3bd4fe96dce17eb2bff380389b24ea325bf54803 (diff)
Merge #5917
5917: Add a command to open docs for the symbol under the cursor r=matklad a=zacps #### Todo - [ ] Decide if there should be a default keybind or context menu entry - [x] Figure out how to get the documentation path for methods and other non-top-level defs - [x] Design the protocol extension. In future we'll probably want parameters for local/remote documentation URLs, so that should maybe be done in this PR? - [x] Code organisation - [x] Tests Co-authored-by: Zac Pullar-Strecker <[email protected]>
Diffstat (limited to 'editors/code/src/commands.ts')
-rw-r--r--editors/code/src/commands.ts25
1 files changed, 23 insertions, 2 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 1a90f1b7d..1445e41d3 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -419,10 +419,31 @@ export function gotoLocation(ctx: Ctx): Cmd {
419 }; 419 };
420} 420}
421 421
422export function openDocs(ctx: Ctx): Cmd {
423 return async () => {
424
425 const client = ctx.client;
426 const editor = vscode.window.activeTextEditor;
427 if (!editor || !client) {
428 return;
429 };
430
431 const position = editor.selection.active;
432 const textDocument = { uri: editor.document.uri.toString() };
433
434 const doclink = await client.sendRequest(ra.openDocs, { position, textDocument });
435
436 if (doclink != null) {
437 vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink));
438 }
439 };
440
441}
442
422export function resolveCodeAction(ctx: Ctx): Cmd { 443export function resolveCodeAction(ctx: Ctx): Cmd {
423 const client = ctx.client; 444 const client = ctx.client;
424 return async (params: ra.ResolveCodeActionParams) => { 445 return async () => {
425 const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, params); 446 const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, null);
426 if (!item) { 447 if (!item) {
427 return; 448 return;
428 } 449 }