mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Add command for only opening external docs and attempt to fix vscode-remote issue
This commit is contained in:
parent
6572ec8d94
commit
4296fe52ba
4 changed files with 47 additions and 17 deletions
|
@ -948,27 +948,51 @@ export function openDocs(ctx: CtxInit): Cmd {
|
|||
const position = editor.selection.active;
|
||||
const textDocument = { uri: editor.document.uri.toString() };
|
||||
|
||||
const doclinks = await client.sendRequest(ra.openDocs, { position, textDocument });
|
||||
const docLinks = await client.sendRequest(ra.openDocs, { position, textDocument });
|
||||
log.debug(docLinks);
|
||||
|
||||
let fileType = vscode.FileType.Unknown;
|
||||
if (typeof doclinks.local === "string") {
|
||||
if (docLinks.local !== undefined) {
|
||||
try {
|
||||
fileType = (await vscode.workspace.fs.stat(vscode.Uri.parse(doclinks.local))).type;
|
||||
fileType = (await vscode.workspace.fs.stat(vscode.Uri.parse(docLinks.local))).type;
|
||||
} catch (e) {
|
||||
log.debug("stat() threw error. Falling back to web version", e);
|
||||
}
|
||||
}
|
||||
|
||||
let doclink;
|
||||
if (fileType & vscode.FileType.File) {
|
||||
// file does exist locally
|
||||
doclink = doclinks.local;
|
||||
} else {
|
||||
doclink = doclinks.web;
|
||||
let docLink = fileType & vscode.FileType.File ? docLinks.local : docLinks.web;
|
||||
if (docLink) {
|
||||
// instruct vscode to handle the vscode-remote link directly
|
||||
if (docLink.startsWith("vscode-remote://")) {
|
||||
docLink = docLink.replace("vscode-remote://", "vscode://vscode-remote/");
|
||||
}
|
||||
const docUri = vscode.Uri.parse(docLink);
|
||||
await vscode.env.openExternal(docUri);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (doclink != null) {
|
||||
await vscode.env.openExternal(vscode.Uri.parse(doclink));
|
||||
export function openExternalDocs(ctx: CtxInit): Cmd {
|
||||
return async () => {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
const client = ctx.client;
|
||||
|
||||
const position = editor.selection.active;
|
||||
const textDocument = { uri: editor.document.uri.toString() };
|
||||
|
||||
const docLinks = await client.sendRequest(ra.openDocs, { position, textDocument });
|
||||
|
||||
let docLink = docLinks.web;
|
||||
if (docLink) {
|
||||
// instruct vscode to handle the vscode-remote link directly
|
||||
if (docLink.startsWith("vscode-remote://")) {
|
||||
docLink = docLink.replace("vscode-remote://", "vscode://vscode-remote/");
|
||||
}
|
||||
const docUri = vscode.Uri.parse(docLink);
|
||||
await vscode.env.openExternal(docUri);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue