-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
VS Code fails to open files from relative paths #139845
Comments
#133438 sounds like it duplicates this issue |
#133438 is a feature request about ordering of quick-open files based on relative path of file in focus in the editor. This issue is a bug about failure to normalise paths with relative directories in them (i.e. |
Right, and I think this is more usual to happen when opening links from the integrated terminal, so adding Daniel. I think before opening quick pick, maybe we should normalize paths if possible? |
An example might help. Consider two files: // repo-dir/sub-dir1/file1.h
#error // repo-dir/sub-dir2/file2.cpp
#include "../sub-dir1/file1.h" At least two problems arise when VS Code is confronted with this structure:
HTH, John |
@bpasero I wouldn't like to say whether there are any gotchas here. You might want to try twice: once with the naked path and if unsuccessful, then try normalised. I don't know if this is more or less messy though. |
But if we were to resolve a path like I think for paths like |
I think eating all leading relative dirs here would produce decent results.
In this case, sub-dir1/file1.h. And I'm not sure it's the common case
anyway.
…On Tue 28 Dec 2021, 15:08 Benjamin Pasero, ***@***.***> wrote:
But if we were to resolve a path like ../sub-dir1/file1.h we need
something to resolve it against. Best we can probably do is to take the
workspace root in this case, though with multi-root workspaces you can end
up having many.
—
Reply to this email directly, view it on GitHub
<#139845 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFTGN5DGNXCZLAXHBX25JDUTHHHTANCNFSM5K4CVPGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
No terminal issue here, I created a similar issue in the past but we now workaround it by just removing the relative prefix: It might make sense to roll that into go to file, but I don't know if there are other implications with that |
Yeah I like the idea of eating the reading relative dirs. |
Note that they are always an indication of an incomplete path, i.e. one in which a directory name followed by a Only if that assumption is somehow false would eating |
This is a relatively big problem for Rust: when rustc prints an error, it is usually relative to Cargo's workspace root, and cargo's workspace root is quite often not the same as Vs Code workspace root. A nice way to solve this would be some kind of an API for extensions to resolve paths -- at least in the case of cargo, correct resolution of realtive paths requires language-specific knowledge which is available in the extension. Actually, I think I've solved that: problem matchers support variable substitiution, and variable substitution supports running custom commands: rust-lang/rust-analyzer#13367 |
This seem to must be solved by checking for files that ended with relative pattern excluding any prefixed '../' because that would be too tricky to know current directory of a script/application during a line output. |
We already do some query normalization here: vscode/src/vs/base/common/fuzzyScorer.ts Lines 894 to 899 in 34e1f76
So maybe a logic to drop |
Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
../
, directory from either the "Go to File..." (Ctrl-P) option or click on such a path as part of compiler output.../
is gone. The file can now be opened by VS Code, even though the physical path is unchanged.Note that I opened an issue as a feature request but have since determined that this is plain broken. (IIRC it works in other tools such as CLion.) Despite a request to reconsider the status of the issue, it remains closed and various open file features remain broken.
Thanks
The text was updated successfully, but these errors were encountered: