microsoft / vscode

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

Support path links that contain spaces in the integrated terminal #97941

Closed nielsvaneck closed 1 year ago

nielsvaneck commented 4 years ago

Steps to Reproduce:

  1. create a vscode python project in a directory with a space that contains some code that produces a failing test or stacktrace
  2. hover over the paths in the stacktrace and notice that those with a space in a directory name are not rendered as links. those without spaces are.

I have created a tiny repo that reproduces the bug: https://github.com/nielsvaneck/vscode_space_path_bug

Does this issue occur when all extensions are disabled?: Yes

Tyriar commented 4 years ago

For the case that you linked I don't think it's expected that it would be linkified on Linux and macOS when the \ before the space is not present, what tools are outputting this? (it's a little more nuanced on Windows)

nielsvaneck commented 4 years ago

For the case that you linked I don't think it's expected that it would be linkified on Linux and macOS when the \ before the space is not present, what tools are outputting this? (it's a little more nuanced on Windows)

just the error output generated by the python interpreter

smcoll commented 4 years ago

Am i having the same issue, or is this different?

In the terminal, paths in the Python traceback are not linked/clickable if there is a space in the path, even though the path is quoted. For example:

File "/home/me/some space/myproject/mypapp/models.py", line 360, in foo
    for obj in qs.distinct()

That seems to be the issue referenced by https://github.com/microsoft/vscode-python/issues/7491 (closed and conversation locked) which was moved to https://github.com/microsoft/vscode/issues/81190 (closed and conversation locked) which is marked as a duplicate of https://github.com/microsoft/vscode/issues/21125 which is supposedly fixed (closed and conversation locked).

Same problem for traceback inlined in the code editor while debugging (i'm not sure what this UI component is called, or where to find out).

Tyriar commented 4 years ago

@smcoll this is the same issue yes.

As of 1.49.0 we have stabilized the link provider API which would allow Python to add better support to Python-specific link formats like this one. The problem we face is the output could be literally everything, so our list of detection continues to grow and get slower and slower. While we could provide better support for spaces in names (that's what this issue is about), Python could improve the support by making this link do something with foo if that's useful

File "/home/me/some space/myproject/mypapp/models.py", line 360, in foo

And maybe even give this line a link to do something useful:

for obj in qs.distinct()

FYI @luabud

smcoll commented 4 years ago

@Tyriar is the line considered Python-specific because it's a format used in Python tracebacks? And are you saying that Python support could choose to link right to that line in the file, for example?

i opened https://github.com/microsoft/vscode-python/issues/7491 hoping that the original issue for the Python extension can be re-opened.

Tyriar commented 4 years ago

@smcoll I commented on https://github.com/microsoft/vscode-python/issues/13989

jackHedaya commented 3 years ago

I don't think this is python specific –– I'm encountering the same bug in Node.js

BenjaminGalliot commented 3 years ago

Same here with Julia.

Version : 1.54.3 OS : Linux x64 5.8.0-48-generic snap

MichaelUray commented 3 years ago

Same problem with Python in Windows 10 using Visual Studio Code (Version: 1.54.3) It does not allow to click hyperlinks in error messages if there is a space in the path. 2021-03-28_21-52-29_thermalCamVideo py_-_thermalCamVideo_-_Visual_Stud

GeorgeLyon commented 3 years ago

This issue also exists with Swift on macOS:

Screen Shot 2021-06-18 at 12 11 41 PM
ItaiPendler commented 3 years ago

Hey, this still happens to me, any updates?

mcurrycl commented 3 years ago

I am also having this issue with Typescript and any other languages I have tried. It makes VSCode unusable for debugging in this sense, I have to manually find the line of code or reinstall Windows to make sure there are no spaces in my linked network and local paths. Please fix.

specOper99 commented 3 years ago

Same here, waiting for a fix :(

shiraze commented 2 years ago

Same issue here with any error that get shown in Terminal. Example lint issue, with a path that contains a space ("IS Transfer"), and clicking the link should open up folder location, but attempts to open up "C:\IS" or "Transfer\Source...." image

AgainPsychoX commented 2 years ago

I am on it, will try my best.

Tyriar commented 2 years ago

@AgainPsychoX this is probably not the best candidate for a contribution as it's not yet known what an efficient solution would look like.

AgainPsychoX commented 2 years ago

I was looking in the related code some time already and I have few ideas. Current solution does not seem to be efficient at all, in few places I can see Regex recompiled and executed even for the very same link.

Key things I would want to do are:

Tyriar commented 2 years ago

@AgainPsychoX thanks for looking into it, in general this sounds good 👍 I'd recommend small focused PRs to make them easier and less risky to review/merge

I can see Regex recompiled and executed even for the very same link.

I think we can just add @memoize to TerminalValidatedLocalLinkProvider._localLinkRegex for example to get caching happening.

Make TerminalLink class abstract, then move tooltip and activation callbacks from LinkManager to TerminalLink specializations (refactor to separate shared code).

I can't remember the reason for this, just make sure you don't introduce a circular dependency when doing this.

Better path detection, I already have interesting piece of more efficient Regexes to detect all current stuff plus spaces

I worry about trying to use regex for path with space detection as well as it's often not clear why a regex is slow and it seems like adding spaces to the regex will make it much more difficult to optimize.

Use more general ITerminalInstance in TerminalLinks/providers (instead just Terminal from xterm), as there are places the code need stuff from the general version (like widget manager; it will avoid listening to changes to update LinkManager I think).

This would add a circular dependency (TerminalInstance -> TerminalLinkManager -> ... -> TerminalLink -> TerminalInstance) which we should avoid as it will make unit testing more cumbersome.

tjx666 commented 2 years ago

eslint same here.

image

surajmandalcell commented 2 years ago

Any update on this?

GoodiesHQ commented 2 years ago

For real, you'd think more people would complain since Windows' default account style has a space in the name... any of my documents have a space in the full path.

bromelio commented 2 years ago

Same issue with paths in VSC's integrated terminal not being linked/clickable if there is a space in the path (in the file name in my case to be more specific). Would be very handy if it worked to directly jump to compilation errors.

Is there any update on this issue? And is there a workaround while we wait?

Tyriar commented 2 years ago

@bromelio no updates other than what is posted. A workaround is to select the link (double click + drag makes this easy), copy, then ctrl+p and paste

bromelio commented 2 years ago

@Tyriar Thanks for the workaround, very attentive of you! I was hoping for something like replace space with \x20 in your upstream powershell code and it'll work, though 😉. But I guess that's simply not possible then? 😞

Anyway, please have this fixed. It's an annoying bug and I think you personally already found a solution (regex)? If your colleagues don't like regex barring any better idea then please simply tell them that users like bugs even less and push it through regardless. Less important things are constantly being implemented while we've already been patient for over two years here. Maybe we have to get a little more cheeky to be heard, too?

Pullusb commented 2 years ago

Hi everyone,

Same here when developing add-on for blender in VScode. The installation of Blender folder sadly have a space in name... "Blender Foundation"

Print something like this on error:

    from . import error_handle
  File "C:\Users\Username\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\myAddon\handle.py", line 176       
    .filename
    ^

I always want to click on that path :rage2: , it even has the line number hint included so it should be able to get there.

+1 for clickable path with space.

For now @Tyriar's workaround save the day (+ we can quickly add line number after path with :258) But still manual where it should be a one click jump to line. Does any VScode user here have found a plug-in that parse the console and that could do that ?

Happy coding all

Tyriar commented 1 year ago

I put this together in https://github.com/microsoft/vscode/pull/169786, here are the detected formats when it gets merged:

I think that should cover the main cases called out in the issue, let me know if your case isn't covered by this.