-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Fix opening links in the terminal with column numbers #210898
Conversation
Honestly I'm not sure this is the best approach. The whole link opening code seems to be a total mess (kind of understandable since there are so many heuristics), but still. I'm not sure why we detect links, then throw away the line info, then detect links again and try to match them back up. Weird. Another thing is that you have the column number of the links in both cases so we should probably check if the passed link actually overlaps the detected link. But I haven't done that. To reproduce the issue and check the fix, make a directory containing these two files:
Now ctrl-click the two After this patch they both work. |
Oh also, to be clear this did work already if the link happens to match the exact path to the file. It's only when it is in a subdirectory somewhere that you see the difference. |
If you open a link from the terminal like `src/foo.ext:5.0-4` then the link passed to `TerminalSearchLinkOpener.open()` will be `src/foo.ext:5.0-4`. It will try to match it against detected links in the line, but it will fail because the detect link has text `src/foo.ext`. Then it will pass the full `src/foo.ext:5.0-4` to the quick picker which doesn't understand that format. This fixes the matching against detected links so it strips potential line/column numbers before matching against the detected links' texts. This only seems to be necessary when the link path doesn't exactly match a file (e.g. if that file is in a subdirectory).
6a0337a
to
0043655
Compare
You might be referring to the Allowing word links to read col/line context at all was actually a very recent change: https://code.visualstudio.com/updates/v1_88#_additional-context-for-word-links |
Ah that kind of makes sense, though it still feels a little round about. So for my example use case we have:
I think in an ideal world if |
@Timmmm you should have seen it before I reworked it into the detectors and openers sub-systems 😉. Doing it this way allows loose coupling and easier testing while keeping the flexibility. The cost of potentially reparsing a single link on activate is fairly low so the extra parse doesn't concern me that much. The more important thing is keeping the flexibility of the current system where there are n detectors each with their own priority can create links of any opener type. |
Created an issue for this bug #216728 |
Thanks! |
Fix opening links in the terminal with column numbers
If you open a link from the terminal like
src/foo.ext:5.0-4
then the link passed toTerminalSearchLinkOpener.open()
will besrc/foo.ext:5.0-4
. It will try to match it against detected links in the line, but it will fail because the detect link has textsrc/foo.ext
. Then it will pass the fullsrc/foo.ext:5.0-4
to the quick picker which doesn't understand that format.This fixes the matching against detected links so it strips potential line/column numbers before matching against the detected links' texts.
Fixes #216728