You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cmd+Click on file:// URIs with line/column in Test Peek window fails #150702
Links in this format in the Test Peek window are underlined and say "Cmd+click" in the hover, but clicking them does not work because of the line/col on the end:
(Same is true of the debug console)
Since this output comes from the test framework, it's not easy for an extension to change it, but it seems like a common enough format that VS Code should handle it.
Reacted by Tom Gilder, Shadab Zafar, Jacob Richman, Kenzie Davisson, Danny Tuppeny, Kevin Moore, Ander Dobo, Greg Spencer, Brian Wilkerson, Nicolas Dion-Bouchard and 12 more
I've added support for it in the debug console in the linked PR.
However, test output is just an editor, and you'll see this syntax is not supported in other editors either. Maybe that's something that we should change. Logan Ramos (@lramos15) do you own the opener service? If not, do you know who to pass it off to?
I believe the code editor creates these links and then passes them into the opener service, but line/col information cannot just be part of the URI path, they have to be provided differently, so the code editor needs to detect accordingly. : is a valid character of a file name btw.
We have a utility method to produce URIs that contain line/col info:
For file uris it doesn't matter if its URI or string because it will always be transformed to URI (this only matters for http and other "external" uris). The issue here is that the opener service (more precisely Benjamin Pasero (@bpasero)'s extractSelection-util ) only looks at the uri-fragement, not at the path. We never used to do that, so feature-request is fair.
Danny Tuppeny (@DanTup) Do you control those messages? Can you create the links as file:///ssss/bbb.txt#L12:111?
Danny Tuppeny (@DanTup) Do you control those messages? Can you create the links as file:///ssss/bbb.txt#L12:111?
Not myself, they're coming from the test runner and/or the VM stack traces. I can file an issue in Dart/test runner about changing them, although it could be quite a breaking change given lots of other code/cools might parse thsee. I don't think Dart is the only place I've seen that format though, so I think having VS Code handle them might benefit other languages/test runners/etc. too.
: is a valid character of a file name btw
Hmm yeah, this seems unfortunate. Is it possible to first try the filename as-is, and if it doesn't exist look for :\d+ from the end as line/cols?
It's a little funny. With just path names we are relaxed and try out more "variations" but when an uri is given we assume that the source knows what it is doing
Although using colons seems ambiguous, I wasn't able to find any real "standards" for adding line/cols. I suspect it's unlikely Dart will change (because it could be quite a breaking change to anything trying to parse stack traces), but if it did, it would probably be more likely if there was some clear standard. I know GitHub uses #Lx:y, but my understanding was that L was for "left" which seems a little odd to use generally here.
I know GitHub uses #Lx:y, but my understanding was that L was for "left" which seems a little odd to use generally here.
It's the first time I hear about "left" and I don't believe that interpretation makes much sense. Still, we support a few variants with and without the _L_ine characters (see docs)
but if it did, it would probably be more likely if there was some clear standard.
suspect it's unlikely Dart will change (because it could be quite a breaking change to anything trying to parse stack traces)
I understand that. IMO the easiest would be to massage these uris in the dart-extension (between receiving and submitting) because you already know what to expect from Dart and you have less/no chances of unwanted uri-breakage (which is a risk VS Code would take if we blindly, without context, change the meaning of uri-handling)
It's the first time I hear about "left" and I don't believe that interpretation makes much sense.
It makes a bit more sense when you view a diff, as changing it to R selects the rows from the right right files (the format seems slightly different now, it used to have the filenames in the URI, but maybe I'm just looking at a different page right now):
IMO the easiest would be to massage these uris in the dart-extension
It's possible to do this for Test Peek, but not for Debug Console, as that comes directly from the debug adapter (which is migrating to the Dart SDK and intended to be editor-agnostic). That also only solves it for Dart, but there are lots of things that use this format - NodeJS which VS Code uses uses the same format itself:
danny@Dannys-MacBook-Pro /tmp % echo "console.trace();" > test.js
danny@Dannys-MacBook-Pro /tmp % node test.js
Trace
at Object.<anonymous> (/private/tmp/test.js:1:9) // <-----------
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
less/no chances of unwanted uri-breakage (which is a risk VS Code would take if we blindly, without context, change the meaning of uri-handling)
I don't think it's really "blindly without context" if you only did it if the original URI doesn't exist (although I don't know how easily you have access to know if it exists where you need this). It just seems like handling it in VS Code would improve a lot of things for a lot of people (not just Dart users) if it were handled.
That also only solves it for Dart, but there are lots of things that use this format - NodeJS which VS Code uses uses the same format itself:
There is a difference between /private/tmp/test.js:1:9 and file:///private/tmp/test.js:1:9 - the latter is an uri and that gives me the impression that the provided information is "more correct" and should be interpreted as-is
the latter is an uri and that gives me the impression that the provided information is "more correct" and should be interpreted as-is
But there's no clear definition of "correct" here. The conventions linked above seem like things that VS Code has decided on (or perhaps borrowed from something like GitHub's URIs) and not some published standard. The closest I could find to a public "spec" is https://datatracker.ietf.org/doc/html/rfc5147 which uses #line=x (which VS Code doesn't support, although I'm not advocating using this).
Without any obvious standard, I'm not sure I understand the reluctance to make VS Code compatible with more formats. It seems like the chance of it doing the wrong thing is almost zero (especially if you try the original URI first, and only fall back to treating the last characters as line/col if the URI doesn't exist). I don't think there's a huge difference between "a file path followed immediately by :1:2" and "a file URI followed immediately by :1:2". In both cases, the :1:2could be part of the file path. Using URIs avoid issues with escaping/spaces with wrapping/different slash directions.
Activity
connor4312 commentedon Jun 6, 2022
I've added support for it in the debug console in the linked PR.
However, test output is just an editor, and you'll see this syntax is not supported in other editors either. Maybe that's something that we should change. Logan Ramos (@lramos15) do you own the opener service? If not, do you know who to pass it off to?
bpasero commentedon Jun 7, 2022
I believe the code editor creates these links and then passes them into the opener service, but line/col information cannot just be part of the URI path, they have to be provided differently, so the code editor needs to detect accordingly.
:is a valid character of a file name btw.We have a utility method to produce URIs that contain line/col info:
vscode/src/vs/platform/opener/common/opener.ts
Line 147 in b3ec818
3 remaining items
jrieken commentedon Jun 10, 2022
For
fileuris it doesn't matter if itsURIorstringbecause it will always be transformed toURI(this only matters for http and other "external" uris). The issue here is that the opener service (more precisely Benjamin Pasero (@bpasero)'sextractSelection-util ) only looks at the uri-fragement, not at the path. We never used to do that, sofeature-requestis fair.Danny Tuppeny (@DanTup) Do you control those messages? Can you create the links as
file:///ssss/bbb.txt#L12:111?DanTup commentedon Jun 11, 2022
Not myself, they're coming from the test runner and/or the VM stack traces. I can file an issue in Dart/test runner about changing them, although it could be quite a breaking change given lots of other code/cools might parse thsee. I don't think Dart is the only place I've seen that format though, so I think having VS Code handle them might benefit other languages/test runners/etc. too.
Hmm yeah, this seems unfortunate. Is it possible to first try the filename as-is, and if it doesn't exist look for
:\d+from the end as line/cols?jrieken commentedon Jun 13, 2022
It's a little funny. With just path names we are relaxed and try out more "variations" but when an uri is given we assume that the source knows what it is doing
DanTup commentedon Jun 13, 2022
Is it feasible to make URIs do something similar?
Although using colons seems ambiguous, I wasn't able to find any real "standards" for adding line/cols. I suspect it's unlikely Dart will change (because it could be quite a breaking change to anything trying to parse stack traces), but if it did, it would probably be more likely if there was some clear standard. I know GitHub uses
#Lx:y, but my understanding was thatLwas for "left" which seems a little odd to use generally here.jrieken commentedon Jun 21, 2022
It's the first time I hear about "left" and I don't believe that interpretation makes much sense. Still, we support a few variants with and without the _L_ine characters (see docs)
I believe uri/url fragments are the closet to such standard. They are meant to represent intra document anchors, like https-anchor links, e.g. https://github.com/Dart-Code/Dart-Code#extension-settings
I understand that. IMO the easiest would be to massage these uris in the dart-extension (between receiving and submitting) because you already know what to expect from Dart and you have less/no chances of unwanted uri-breakage (which is a risk VS Code would take if we blindly, without context, change the meaning of uri-handling)
DanTup commentedon Jun 21, 2022
It makes a bit more sense when you view a diff, as changing it to
Rselects the rows from the right right files (the format seems slightly different now, it used to have the filenames in the URI, but maybe I'm just looking at a different page right now):It's possible to do this for Test Peek, but not for Debug Console, as that comes directly from the debug adapter (which is migrating to the Dart SDK and intended to be editor-agnostic). That also only solves it for Dart, but there are lots of things that use this format - NodeJS which VS Code uses uses the same format itself:
I don't think it's really "blindly without context" if you only did it if the original URI doesn't exist (although I don't know how easily you have access to know if it exists where you need this). It just seems like handling it in VS Code would improve a lot of things for a lot of people (not just Dart users) if it were handled.
jrieken commentedon Jun 22, 2022
There is a difference between
/private/tmp/test.js:1:9andfile:///private/tmp/test.js:1:9- the latter is an uri and that gives me the impression that the provided information is "more correct" and should be interpreted as-isDanTup commentedon Jun 22, 2022
But there's no clear definition of "correct" here. The conventions linked above seem like things that VS Code has decided on (or perhaps borrowed from something like GitHub's URIs) and not some published standard. The closest I could find to a public "spec" is https://datatracker.ietf.org/doc/html/rfc5147 which uses
#line=x(which VS Code doesn't support, although I'm not advocating using this).Without any obvious standard, I'm not sure I understand the reluctance to make VS Code compatible with more formats. It seems like the chance of it doing the wrong thing is almost zero (especially if you try the original URI first, and only fall back to treating the last characters as line/col if the URI doesn't exist). I don't think there's a huge difference between "a file path followed immediately by
:1:2" and "a file URI followed immediately by:1:2". In both cases, the:1:2could be part of the file path. Using URIs avoid issues with escaping/spaces with wrapping/different slash directions.Is this something you'd accept a PR for?
DanTup commentedon Feb 6, 2024
Looks like this was fixed via #193629. Works fine now:
links.mp4