mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 03:14:30 +00:00
Add rust-analyzer.gotoLocation
command
This commit is contained in:
parent
d4e75312ba
commit
7e986d1504
6 changed files with 25 additions and 8 deletions
|
@ -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) => {
|
||||
|
|
|
@ -135,6 +135,9 @@ export class Config {
|
|||
return {
|
||||
enable: this.get<boolean>("hoverActions.enable"),
|
||||
implementations: this.get<boolean>("hoverActions.implementations"),
|
||||
run: this.get<boolean>("hoverActions.run"),
|
||||
debug: this.get<boolean>("hoverActions.debug"),
|
||||
gotoTypeDef: this.get<boolean>("hoverActions.gotoTypeDef"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue