Skip to content
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

Merged
merged 2 commits into from
May 20, 2024
Merged

Conversation

pascalkuthe
Copy link
Member

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 with cd.

@pascalkuthe pascalkuthe added E-easy Call for participation: Experience needed to fix: Easy / not much S-waiting-on-review Status: Awaiting review from a maintainer. labels May 11, 2024
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
Copy link
Contributor

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.

the-mikedavis
the-mikedavis previously approved these changes May 13, 2024
Copy link
Member

@the-mikedavis the-mikedavis left a 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

helix-stdx/src/env.rs Outdated Show resolved Hide resolved
@archseer archseer merged commit 8444f52 into master May 20, 2024
6 checks passed
@archseer archseer deleted the pwd branch May 20, 2024 12:44
Vulpesx pushed a commit to Vulpesx/helix that referenced this pull request Jun 7, 2024
…or#10728)

* correctly handle opening helix inside symlinked directory

* Update helix-stdx/src/env.rs

---------

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Experience needed to fix: Easy / not much S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants