-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Document links provided by a custom language server conflict with links provided by VS Code typescript #136433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The TS extension doesn't have a document link provider so it sounds like you are talking about definition links? Is your extension using |
Hi @mjbvz, thanks for responding I'm not using any of those. The extension is providing the links through a language server, similar to what This file implements the logic behind the link generation: And this file, lines 63 to 83, configures and starts the language server: Having said that, I've also tested using a |
Hello @mjbvz, the problem still exists, any updates? |
This is a duplicate of #81520 I'll check in a fix for TS resolving the wrong path but we still plan on returning a definition. Until #81520 is fixed, this means both the definition and document link will be invoked on click @Henato One other note: in your sample, you hardcode the scheme |
For #136433 These paths always have to start with `/`
Uh oh!
There was an error while loading. Please reload this page.
Issue Type: Bug
We have a use case in our extension (Engine DevTools) that uses a language server to create document links in virtual files.
Some of those links are created for fragments of text inside a require, for example: "require('./foo.js')" or "require('fs')". We would, in this example, turn the fragments "foo.js" and "fs" into links. Those would usually be external links to be handled by a UriHandler in various ways.
This used to work for virtual files, but recently, links inside a require started to conflict with the links provided by typescript by default. Right now, VS Code tries to open both links.
Steps to reproduce:
1 - Clone and debug the extension sample in https://github.com/Henato/doc-link-sample.
2 - While debugging, run the commands "MemFS: Setup Workspace" and then "MemFS: Create Files".
3 - Open testExternalLinks.js and ctrl+click on '.foo.js'. It should open the desired file and also throw an error.
4 - Close foo.js and return to testExternalLinks.js.
5 - In testExternalLinks.js, ctrl+click on 'fs'. It should open both 'foo.js' and the d.ts for the "fs" module.
Stack for the error in step 3:
There is also a testInternalLinks.js file, which is similar but uses regular URIs as targets for the links instead of external links. In this example, the links behave as expected, with both links only opening the
foo.js
file.It is important to note, though, that even regular ("internal") links could fail and have the same behavior as external links if:
1 - The methods from the MemFS file system provider are async, or;
2 - The targets for the links are lazily resolved in
connection.onDocumentLinkResolve
, in the language server.All the examples mentioned above were also tested on insiders, which rendered equal results for internal links, but completely failed when opening external links, throwing the error:
"Unable to resolve text model content for resource vscode://nginstack.memfs-doclink-error/memfs/foo.js"
Is there any workaround that we could implement to fix this behavior, or is there something we are doing wrong in any of the examples above?
VS Code version: Code 1.61.2 (6cba118, 2021-10-19T14:57:20.575Z)
OS version: Windows_NT x64 10.0.22000
Restricted Mode: No
System Info
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: