From 4d6c6a6b1e00f61af96e16386c7f03f83f96a173 Mon Sep 17 00:00:00 2001 From: vsrs Date: Wed, 10 Jun 2020 16:15:28 +0300 Subject: Fix rust-analyzer.debug.openDebugPane option --- editors/code/src/config.ts | 2 +- editors/code/src/debug.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'editors/code') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index d8f0037d4..22ebdf636 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -117,7 +117,7 @@ export class Config { return { engine: this.get("debug.engine"), engineSettings: this.get("debug.engineSettings"), - openUpDebugPane: this.get("debug.openUpDebugPane"), + openDebugPane: this.get("debug.openDebugPane"), sourceFileMap: sourceFileMap }; } diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index a0c9b3ab2..61c12dbe0 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -82,7 +82,7 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise Date: Wed, 10 Jun 2020 23:01:19 +0300 Subject: Add `rust-analyzer.gotoLocation` command --- editors/code/package.json | 5 +++++ editors/code/src/commands.ts | 14 ++++++++++++++ editors/code/src/config.ts | 3 +++ editors/code/src/main.ts | 1 + 4 files changed, 23 insertions(+) (limited to 'editors/code') diff --git a/editors/code/package.json b/editors/code/package.json index 3acc375f6..e6ceb235f 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -510,6 +510,11 @@ "type": "boolean", "default": true }, + "rust-analyzer.hoverActions.gotoTypeDef": { + "markdownDescription": "Whether to show `Go to Type Definition` action. Only applies when `#rust-analyzer.hoverActions.enable#` is set.", + "type": "boolean", + "default": true + }, "rust-analyzer.linkedProjects": { "markdownDescription": "Disable project auto-discovery in favor of explicitly specified set of projects. \nElements must be paths pointing to Cargo.toml, rust-project.json, or JSON objects in rust-project.json format", "type": "array", diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 3e9c3aa0e..48a25495f 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -353,6 +353,20 @@ export function applyActionGroup(_ctx: Ctx): Cmd { }; } +export function gotoLocation(ctx: Ctx): Cmd { + return async (locationLink: lc.LocationLink) => { + const client = ctx.client; + if (client) { + const uri = client.protocol2CodeConverter.asUri(locationLink.targetUri); + let range = client.protocol2CodeConverter.asRange(locationLink.targetSelectionRange); + // collapse the range to a cursor position + range = range.with({ end: range.start }); + + await vscode.window.showTextDocument(uri, { selection: range }); + } + }; +} + export function resolveCodeAction(ctx: Ctx): Cmd { const client = ctx.client; return async (params: ra.ResolveCodeActionParams) => { diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 22ebdf636..9591d4fe3 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -135,6 +135,9 @@ export class Config { return { enable: this.get("hoverActions.enable"), implementations: this.get("hoverActions.implementations"), + run: this.get("hoverActions.run"), + debug: this.get("hoverActions.debug"), + gotoTypeDef: this.get("hoverActions.gotoTypeDef"), }; } } diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a92c676fa..270fbcb64 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -100,6 +100,7 @@ export async function activate(context: vscode.ExtensionContext) { ctx.registerCommand('applySnippetWorkspaceEdit', commands.applySnippetWorkspaceEditCommand); ctx.registerCommand('resolveCodeAction', commands.resolveCodeAction); ctx.registerCommand('applyActionGroup', commands.applyActionGroup); + ctx.registerCommand('gotoLocation', commands.gotoLocation); ctx.pushCleanup(activateTaskProvider(workspaceFolder)); -- cgit v1.2.3