-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
correctly handle opening helix inside symlinked directory #10728
Conversation
helix-stdx/src/env.rs
Outdated
let mut cwd = CWD.write().unwrap(); | ||
*cwd = Some(path.clone()); | ||
// implementation of crossplatform pwd -L | ||
// we want pwd -L so that symlinked directories are handeled correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's handled
not handeled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the typo this looks good! For context I use https://github.com/nix-community/impermanence so any long-lived files usually live under a symlink, for example ~/src/helix
is a symlink to /nix/persist/home/michael/src/helix
. So the difference between symlinks and regular files bites me fairly often. I've been testing this locally and it seems to work perfectly! Opening files with relative paths or relative paths with absolute paths (/home/michael/src/helix/README.md
for example) properly shows them as relative in the statusline
…or#10728) * correctly handle opening helix inside symlinked directory * Update helix-stdx/src/env.rs --------- Co-authored-by: Blaž Hrastnik <[email protected]>
…or#10728) * correctly handle opening helix inside symlinked directory * Update helix-stdx/src/env.rs --------- Co-authored-by: Blaž Hrastnik <[email protected]>
get_current_directory alnways returns a cannonicalized path (since cwd is just a file descriptor that is passed to realpath). That means that opening any file inside a symlinked directory would show that file as an absolute path outised the cwd instead of as an relative path (since we don't cannonicalize/resolve symlinks normally). To fix that I made helix mirror the behavior of
pwd -L
. We use PWD environment variable set by the shell which has a "memory" of which symlinks were transversed withcd
.