microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.28k stars 29.31k forks source link

Debug console link detection issues #34026

Open isidorn opened 7 years ago

isidorn commented 7 years ago

Also consider a way for extensions to contribute link detection rules

DanTup commented 6 years ago

@sandy081 I'm just trying to step through this code to understand why my links aren't being detected, but I'm really confused by this code:

https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/browser/linkDetector.ts#L48-L53

            while (match !== null) {
                let resource: uri = null;
                if (!resource) {
                    match = pattern.exec(text);
                    continue;
                }

As far as I can tell, the rest of the code in this block will never execute - resource is always initialised as null then the if statement continues?

DanTup commented 6 years ago

In fact, it looks like maybe the minifier stripped all the code out because of that?

screen shot 2018-03-29 at 12 27 23

DanTup commented 6 years ago

@isidorn Is anyone able to review the comments above? Am I misreading the code or is this a bug that means this will never work? :(

isidorn commented 6 years ago

@DanTup yes this seems like a clear bug on our end. Would you be interested in providing a PR which fixes this. This was initialy done by our previous internt @michelkaporin

DanTup commented 6 years ago

@isidorn I haven't contributed any real code before, do I need to (and if so, are there instructions on how to) run Code from source? (I checked contributing.md but it doesn't seem to cover it). Also, are there automated tests around this sort of functionality I could extend?

isidorn commented 6 years ago

@DanTup https://github.com/Microsoft/vscode/wiki/How-to-Contribute We do not have tests around link detection unfortunetly, so you would have to manually test it out

@gregvanl our contributing.md should have a pointer to our wiki how to contribute page imho

DanTup commented 6 years ago

I did have this on my list to try and look at, but I never gotten around to it. I think it's unlikely to happen anytime soon so it may be better for someone else to look at.

(I do a lot of people would benefit in fixing - many issues have been closed as dupes of this, though is in the backlog marked as debt, when the above is really a bug).

DanTup commented 5 years ago

@isidorn Coming back to this, I noticed fixing the detection won't work for us, as our links have been rewritten as URIs, like:

flutter: #0      _GalleryAppState.build (package:flutter_gallery/gallery/app.dart:131:5)
flutter: #1      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)

Was there any progress on allowing extensions to contribute rules for link detection? (I couldn't find anything)

isidorn commented 5 years ago

No porgress here

mymikemiller commented 5 years ago

I just made a Pull Request that brings this feature back (#65929). I'm curious to hear your thoughts, @isidorn.

DanTup commented 5 years ago

FWIW, while setting up a repro using the mock debugger today, I noticed that OutputEvents can be given source locations (it didn't show in the completion until I cast it like new OutputEvent(${message}\n, category) as OutputEvent & DebugProtocol.OutputEvent.

So, I realised I could regex my paths out of the call stacks and just attach them to each line this way.

Before (no links):

screenshot 2019-01-07 at 11 40 09 am

After (links):

screenshot 2019-01-07 at 11 40 58 am

As an advantage, this allows mapping the package: URIs to the correct source file, and also allows truncating the visible file path if desired to take up less space.

gregg-miskelly commented 5 years ago

@isidorn This issue was also used to track making it possible for extensions to add additional regex's (see your comment at the end of https://github.com/Microsoft/vscode/pull/30882). Is that now possible, or should I open a new issue?

isidorn commented 5 years ago

@gregg-miskelly let's reopen this issue. We have cleaned up some link detection however it is still not perfect obviously.

LWChris commented 5 years ago

Extension host protocol does also break grafik

octref commented 5 years ago

Would love to get a link detection API I can use internally for hover/completion when doing plaintext handling in completion / hover: https://github.com/microsoft/vscode/issues/79841

lichray commented 5 years ago

Please fix this for GDB under msys2.

jribbens commented 3 years ago

I've noticed that link detection is inconsistent between debug console and terminal. So for example "http://example.com/abcd(efgh)" will be detected as a link in both, but the final ) will be (correctly) detected as being part of the link in the terminal but not in the debug console. Is this the same issue as this one or should I open a new one?

MarByteBeep commented 3 years ago

Not sure if this is entirely related, but I have a watch task compiling my TypeScript code in the background. When it errors, it produces an output like so:

main.ts:14:11 - error TS2551: Property 'losg' does not exist on type 'Console'. Did you mean 'log'?   

14   console.losg(`${p_data.name} => ${p_data.json ? JSON.stringify(p_data.json) : p_data.interval}`);

It would be ideal to be able to left click on that main.ts:14:11 string to get me to that line, similar to the debug window functionality.

As a work-around I can ctrl-click on that string, which seems to copy that text to the search field in the main editor, after which I can press enter, to get me to the correct file/line. That's workable, but obviously not as quick as a single click.

levrik commented 3 years ago

Case moved here from #135770

For this Python stacktrace snippet the integrated terminal correctly detects the link including the line 99. On the internal console it only detects the file path but not the line information which is quite annoying.

File "/Users/levrik/code/project/api/context.py", line 99, in __init__
    self.document_service = DocumentService(
jsolly commented 2 years ago

I am running into the same issue as @levrik. Clicking on a Python stacktrace takes me to the top of the file (not the line of code) when using internal console. MacOS Monterey VScode Version: 1.66.0

truongn1 commented 1 year ago

Any consideration to fix this? Thanks

jribbens commented 1 year ago

I notice that the link detection has changed in release 1.75.0 - and from my point of view the changes have made it worse. I frequently have links that look like https://example.com/path(abc,def), and previously this link would be correctly detected in the terminal (but not in the debug console, where the final ) would be omitted)... but now in the terminal the link is wrongly terminated before the ,.

roblourens commented 1 year ago

Terminal link detection is not related to this, please file a separate issue @jribbens

jribbens commented 1 year ago

@roblourens What is this ticket about then? If it's about the debug console link detection, then my comment from April 2021 still stands - given a URL like https://example.com/path(abc,def) the debug console omits the close bracket from the link.

roblourens commented 1 year ago

It's about the debug console, but if I understand your comment correctly, you are saying that something in the terminal regressed?

jribbens commented 1 year ago

The debug console behaves the same as it has for a long time, in that for URLs of the form I mentioned (which I use a lot), it fails to include the final ). Obviously "URL guessing" can never be perfect, but I expected VSCode's debug tab to get it right, because VSCode's terminal tab got it right. The recent regression is that the terminal tab now gets it even wronger than the debug tab, and terminates the URL at the ,. So previously one tab got it right and one got it wrong, now they both get it wrong, but in different ways ;-)

roblourens commented 1 year ago

Yes, sharing link detection implementation would also be a good thing for us to get to. It would be helpful to file an issue for the terminal regression so that we can fix that.

jribbens commented 1 year ago

@roblourens Ok I've opened a separate issue #174009

ngduchuan commented 10 months ago

FWIW, while setting up a repro using the mock debugger today, I noticed that OutputEvents can be given source locations (it didn't show in the completion until I cast it like new OutputEvent(${message}\n, category) as OutputEvent & DebugProtocol.OutputEvent.

So, I realised I could regex my paths out of the call stacks and just attach them to each line this way.

Before (no links):

screenshot 2019-01-07 at 11 40 09 am

After (links):

screenshot 2019-01-07 at 11 40 58 am

As an advantage, this allows mapping the package: URIs to the correct source file, and also allows truncating the visible file path if desired to take up less space.

@DanTup I also face this problem, but I didn't understand how you did. Could you please guide it in some detail? Many thanks

DanTup commented 10 months ago

@ngduchuan are you an extension author, or a Flutter user? If an extension author, you need to set the source field on your OutputEvents. If you're a Flutter user and not seeing these links, please ensure you're on the latest version of Flutter and if you're not seeing links you'd expect, please file an issue at https://github.com/Dart-Code/Dart-Code.

MarByteBeep commented 10 months ago

I still have issues with link detection (and specifically Ctrl Clicking the link) in vscode as well. For instance vscode does seem to detect the following link, and I'm able to Ctrl click it

TypeError: fetch failed
    at fetch (C:\git\myproject\node_modules\undici\index.js:115:13)

But when prefixed with file:///, the link is recognized, but I'm not able to Ctrl click it:

    at async apiCall (file:///C:/git/myproject/src/lib/api.js:284:19)

Any thoughts?

DanTup commented 10 months ago

But when prefixed with file:///, the link is recognized, but I'm not able to Ctrl click it:

 at async apiCall (file:///C:/git/myproject/src/lib/api.js:284:19)

This is probably related to https://github.com/microsoft/vscode/issues/150702. VS Code doesn't handle file:/// URIs that have line/col on the end using colons. The argument is that the colons could be part of the filename. Personally I think it's the wrong call given how many languages are outputting links in this format.

MarByteBeep commented 10 months ago

Yes, especially since the first one (on the call stack) has a "correct" url, but ends up deep in the nodejs library. The actual link that would make sense for me to focus on would be the second one. And that one cannot be clicked. Not ideal 😉

DanTup commented 9 months ago

Have there been changes around this? In the latest release notes I see:

File protocol URIs (file://) now support line and column number extensions at the end, like most other links. The new # format is also supported.

But I can't find any issue or PR related to this. I'm specifically interested in what "line and column number extensions" mean. Is file:///foo:1:2 finally supported, or is this meant to be a description of https://github.com/microsoft/vscode/issues/193384 (which is not about file URIs, but file paths ending with ranges)?

roblourens commented 9 months ago

In the release notes, that is specifically for the terminal. No progress in the debug console, unfortunately.

DanTup commented 9 months ago

@roblourens do you know where the Issue/PR for the change that was made is? I'm just about the specifics of it because I'd opened some issues like https://github.com/microsoft/vscode/issues/150702 (which I think might be a terminal now?) with issues in this area, but it's not clear if this fix helps (the suggestion was that colons on a file:/// URI are not allowed because they're valid as part of a filename, and I'm wondering if this stance has changed).

roblourens commented 9 months ago

https://github.com/microsoft/vscode/issues/193629