Use vscode.env.openExternal instead of the vscode.open command for docs

According to the VS Code documentation, the vscode.open command opens the URL
_in the editor_ (https://code.visualstudio.com/api/references/commands).
However, in reality, it seems to do so only for file:// URLs, falling back to
other applications for other URL schemes (at least for HTTP/HTTPS).

Until now, the URL to the documentation was always HTTP based, so using the
vscode.open command was perfectly fine. However, displaying local documentation
will be supported from now on (see next commit). Local documentation is not
HTTP-based, but instead addressed via a file:// URL. The file URL would
therefore be opened in VS Code instead of in the browser — this is definitely
not what the user wants.

Therefore, the vscode.env.openExternal function is used instead, this function
never opens the URL in VS Code.
This commit is contained in:
Elias Holzmann 2023-10-08 03:31:23 +02:00
parent b1f89a84ab
commit 3dfc1bfc67

View file

@ -950,7 +950,7 @@ export function openDocs(ctx: CtxInit): Cmd {
const doclink = await client.sendRequest(ra.openDocs, { position, textDocument });
if (doclink != null) {
await vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink));
await vscode.env.openExternal(vscode.Uri.parse(doclink));
}
};
}