-
Notifications
You must be signed in to change notification settings - Fork 28.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
terminal cmd+click soft link file but open in original folder #129023
Comments
(Experimental duplicate detection) |
It's also OK when I tried in local machine, but was wrong when tried in remote machine using extension "Remote - SSH". |
This was on Windows via WSL which should work the same as Windows -> SSH. 🤷 |
@Tyriar I'm on MAC OS^_^ |
I wouldn't expect that to make a difference, but it's possible. |
@Tyriar Supply the screenshot。The step difference with you is I "cmd+click" the relative path on |
Sorry I closed this issue carelessly. |
That's great thanks, can repro. It happens with |
Ok more info on repro which is much more involved than initially thought:
*Note that if you reload the window you need to hit enter and wait before it will happen |
What I've found so far
|
For Linux it happens because of the readlink here: https://github.com/Microsoft/vscode/blob/424a1166f37f10e11f8f88dbbb5d6930a8f9d3f9/src/vs/platform/terminal/node/terminalProcess.ts#L507-L507. Not sure it's possible using |
Asked on unix stack exchange: https://unix.stackexchange.com/q/659464/115410 |
If all else fails we could check if the initial cwd was a symlink and that is resolves to the current cwd and use that. It's not ideal, plus it would fall apart if you actually cd into |
Closing as the only way to fix this would be using a hack, plus it's not that big of an issue really. |
In some environments, it is common for a user's home directory to be a symbolic link (symlink) to a different filesystem location. For example, for user 'john' the value of the HOME environment variable is '/home/john' but '/home/john' is actually a symbolic link to '/some/place/else/homes/john'. This setup is very common on high performance computing (HPC) systems. When such a user opens a folder in VS Code, the 'Open Folder' dialog defaults to the user' HOME, i.e. '/home/jane'. If the user opens a folder located somwhere in their home, this directory is opened by VS Code unresolved, i.e. '/home/jane/project'. When the users opens a file by Ctrl-clicking a file link in the integrated terminal, the resolved file path is opened, i.e. '/some/place/else/homes/jane/project/file'. This is suboptimal because if 'file' was already opened in the workspace, opening it from the integrated terminal opens a second tab instead of focusing on the already opened tab, as VS Code does not recognize it is the same file. This is made worse by the fact that some language extensions that provide 'Outline' functionality do not work at all in this newly opened tab from the resolved file path. To fix this, canonicalize the value of a user's home directory early in the environment initialization, by calling 'realpathSync' on the path returned by Node's 'homedir()' in the constructor of NativeEnvironmentService. This results in the resolved value of a user's home directory being the default location for the 'Open Folder' dialog. Since now the already opened 'file' and 'file' opened from the integrated terminal have the same path, VS Code does recognize they are indeed the same file, and focuses on the already opened tab instead of opening a second tab. Test this by temporarily changing the value of HOME (USERPROFILE on Windows) to point to a symlink and verifying that the userHome property of a newly created NativeEnvironmentService is returned as resolved. Note that for some reason, in order for 'fs.rmSync' to correctly clean up the symlink after the test, it has to be called with 'recursive: true'. Fixes: microsoft#118973 Fixes: microsoft#129023
In some environments, it is common for a user's home directory to be a symbolic link (symlink) to a different filesystem location. For example, for user 'john' the value of the HOME environment variable is '/home/john' but '/home/john' is actually a symbolic link to '/some/place/else/homes/john'. This setup is very common on high performance computing (HPC) systems. When such a user opens a folder in VS Code, the 'Open Folder' dialog defaults to the user' HOME, i.e. '/home/jane'. If the user opens a folder located somwhere in their home, this directory is opened by VS Code unresolved, i.e. '/home/jane/project'. When the users opens a file by Ctrl-clicking a file link in the integrated terminal, the resolved file path is opened, i.e. '/some/place/else/homes/jane/project/file'. This is suboptimal because if 'file' was already opened in the workspace, opening it from the integrated terminal opens a second tab instead of focusing on the already opened tab, as VS Code does not recognize it is the same file. This is made worse by the fact that some language extensions that provide 'Outline' functionality do not work at all in this newly opened tab from the resolved file path. To fix this, canonicalize the value of a user's home directory early in the environment initialization, by calling 'realpathSync' on the path returned by Node's 'homedir()' in the constructor of NativeEnvironmentService. This results in the resolved value of a user's home directory being the default location for the 'Open Folder' dialog. Since now the already opened 'file' and 'file' opened from the integrated terminal have the same path, VS Code does recognize they are indeed the same file, and focuses on the already opened tab instead of opening a second tab. Test this by temporarily changing the value of HOME (USERPROFILE on Windows) to point to a symlink and verifying that the userHome property of a newly created NativeEnvironmentService is returned as resolved. Note that for some reason, in order for 'fs.rmSync' to correctly clean up the symlink after the test, it has to be called with 'recursive: true'. Fixes: microsoft#118973 Fixes: microsoft#129023
In some environments, it is common for a user's home directory to be a symbolic link (symlink) to a different filesystem location. For example, for user 'jane' the value of the HOME environment variable is '/home/jane' but '/home/jane' is actually a symbolic link to '/some/place/else/homes/jane'. This setup is very common on high performance computing (HPC) systems. When such a user opens a folder in VS Code, the 'Open Folder' dialog defaults to the user' HOME, i.e. '/home/jane'. If the user opens a folder located somwhere in their home, this directory is opened by VS Code unresolved, i.e. '/home/jane/project'. When the users opens a file by Ctrl-clicking a file link in the integrated terminal, the resolved file path is opened, i.e. '/some/place/else/homes/jane/project/file'. This is suboptimal because if 'file' was already opened in the workspace, opening it from the integrated terminal opens a second tab instead of focusing on the already opened tab, as VS Code does not recognize it is the same file. This is made worse by the fact that some language extensions that provide 'Outline' functionality do not work at all in this newly opened tab from the resolved file path. To fix this, canonicalize the value of a user's home directory early in the environment initialization, by calling 'realpathSync' on the path returned by Node's 'homedir()' in the constructor of NativeEnvironmentService. This results in the resolved value of a user's home directory being the default location for the 'Open Folder' dialog. Since now the already opened 'file' and 'file' opened from the integrated terminal have the same path, VS Code does recognize they are indeed the same file, and focuses on the already opened tab instead of opening a second tab. Test this by temporarily changing the value of HOME (USERPROFILE on Windows) to point to a symlink and verifying that the userHome property of a newly created NativeEnvironmentService is returned as resolved. Note that for some reason, in order for 'fs.rmSync' to correctly clean up the symlink after the test, it has to be called with 'recursive: true'. Fixes: microsoft#118973 Fixes: microsoft#129023
In some environments, it is common for a user's home directory to be a symbolic link (symlink) to a different filesystem location. For example, for user 'jane' the value of the HOME environment variable is '/home/jane' but '/home/jane' is actually a symbolic link to '/some/place/else/homes/jane'. This setup is very common on high performance computing (HPC) systems. When such a user opens a folder in VS Code, the 'Open Folder' dialog defaults to the user' HOME, i.e. '/home/jane'. If the user opens a folder located somwhere in their home, this directory is opened by VS Code unresolved, i.e. '/home/jane/project'. When the users opens a file by Ctrl-clicking a file link in the integrated terminal, the resolved file path is opened, i.e. '/some/place/else/homes/jane/project/file'. This is suboptimal because if 'file' was already opened in the workspace, opening it from the integrated terminal opens a second tab instead of focusing on the already opened tab, as VS Code does not recognize it is the same file. This is made worse by the fact that some language extensions that provide 'Outline' functionality do not work at all in this newly opened tab from the resolved file path. To fix this, canonicalize the value of a user's home directory early in the environment initialization, by calling 'realpathSync' on the path returned by Node's 'homedir()' in the constructor of NativeEnvironmentService. This results in the resolved value of a user's home directory being the default location for the 'Open Folder' dialog. Since now the already opened 'file' and 'file' opened from the integrated terminal have the same path, VS Code does recognize they are indeed the same file, and focuses on the already opened tab instead of opening a second tab. Test this by temporarily changing the value of HOME (USERPROFILE on Windows) to point to a symlink and verifying that the userHome property of a newly created NativeEnvironmentService is returned as resolved. Note that for some reason, in order for 'fs.rmSync' to correctly clean up the symlink after the test, it has to be called with 'recursive: true'. Fixes: microsoft#118973 Fixes: microsoft#129023
In some environments, it is common for a user's home directory to be a symbolic link (symlink) to a different filesystem location. For example, for user 'jane' the value of the HOME environment variable is '/home/jane' but '/home/jane' is actually a symbolic link to '/some/place/else/homes/jane'. This setup is very common on high performance computing (HPC) systems. When such a user opens a folder in VS Code, the 'Open Folder' dialog defaults to the user' HOME, i.e. '/home/jane'. If the user opens a folder located somwhere in their home, this directory is opened by VS Code unresolved, i.e. '/home/jane/project'. When the users opens a file by Ctrl-clicking a file link in the integrated terminal, the resolved file path is opened, i.e. '/some/place/else/homes/jane/project/file'. This is suboptimal because if 'file' was already opened in the workspace, opening it from the integrated terminal opens a second tab instead of focusing on the already opened tab, as VS Code does not recognize it is the same file. This is made worse by the fact that some language extensions that provide 'Outline' functionality do not work at all in this newly opened tab from the resolved file path. To fix this, canonicalize the value of a user's home directory early in the environment initialization, by calling 'realpathSync' on the path returned by Node's 'homedir()' in the constructor of NativeEnvironmentService. This results in the resolved value of a user's home directory being the default location for the 'Open Folder' dialog. Since now the already opened 'file' and 'file' opened from the integrated terminal have the same path, VS Code does recognize they are indeed the same file, and focuses on the already opened tab instead of opening a second tab. Test this by temporarily changing the value of HOME (USERPROFILE on Windows) to point to a symlink and verifying that the userHome property of a newly created NativeEnvironmentService is returned as resolved. Note that for some reason, in order for 'fs.rmSync' to correctly clean up the symlink after the test, it has to be called with 'recursive: true'. Fixes: microsoft#118973 Fixes: microsoft#129023
Issue Type: Bug
1、I'm using extension "Remote - SSH" develop in remote machine
2、My home folder is "/home/xxx/" which is a soft link to /data00/home/xxx
3、Open a folder "/home/xxx/project" in remote machine with vscode
4、 In integrated terminal use "git grep --line-number " to search some content in folder "/home/xxx/project", and "cmd+click" the file path
5、vscode open the file in origin folder "/data00/home/xxx/project/yyy.go", but I think it should be open in "/home/xxx/project/yyy.go", becase my workspace folder in vscode is "/home/xxx/project"
VS Code version: Code 1.58.2 (c3f1263, 2021-07-14T22:09:06.581Z)
OS version: Darwin x64 20.5.0
Restricted Mode: No
Remote OS version: Linux x64 4.19.117.bsk.6-amd64
Remote OS version: Linux x64 4.19.117.bsk.6-amd64
Remote OS version: Linux x64 4.19.117.bsk.6-amd64
Remote OS version: Linux x64 4.19.117.bsk.6-amd64
System Info
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Extensions (10)
A/B Experiments
The text was updated successfully, but these errors were encountered: