mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
add open Cargo.toml action
This commit is contained in:
parent
111cc34c8f
commit
b1b7727e04
15 changed files with 114 additions and 42 deletions
|
@ -188,6 +188,27 @@ export function parentModule(ctx: Ctx): Cmd {
|
|||
};
|
||||
}
|
||||
|
||||
export function openCargoToml(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
const editor = ctx.activeRustEditor;
|
||||
const client = ctx.client;
|
||||
if (!editor || !client) return;
|
||||
|
||||
const response = await client.sendRequest(ra.openCargoToml, {
|
||||
textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
|
||||
});
|
||||
if (!response) return;
|
||||
|
||||
const uri = client.protocol2CodeConverter.asUri(response.uri);
|
||||
const range = client.protocol2CodeConverter.asRange(response.range);
|
||||
|
||||
const doc = await vscode.workspace.openTextDocument(uri);
|
||||
const e = await vscode.window.showTextDocument(doc);
|
||||
e.selection = new vscode.Selection(range.start, range.start);
|
||||
e.revealRange(range, vscode.TextEditorRevealType.InCenter);
|
||||
};
|
||||
}
|
||||
|
||||
export function ssr(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue