-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
feat: make hyperlinks usable inside a WSL environment (support all paths) #925
Open
opalmay
wants to merge
1
commit into
eza-community:main
Choose a base branch
from
opalmay:feat_wsl_hyperlinks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−4
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daviessm
reviewed
Apr 9, 2024
opalmay
force-pushed
the
feat_wsl_hyperlinks
branch
3 times, most recently
from
April 10, 2024 08:18
7c46306
to
8f09929
Compare
gierens
approved these changes
Jul 9, 2024
PThorpe92
approved these changes
Jul 10, 2024
cafkafk
force-pushed
the
feat_wsl_hyperlinks
branch
from
October 18, 2024 14:20
94fd70b
to
d59c615
Compare
cafkafk
requested changes
Oct 18, 2024
Comment on lines
+435
to
+459
let distro_name = std::env::var("WSL_DISTRO_NAME").ok(); | ||
let path = if let Some(distro_name) = distro_name { | ||
if abs_path.starts_with("/mnt/") { | ||
let parts: Vec<&str> = abs_path.split('/').collect(); | ||
if parts.len() > 2 | ||
&& parts[2].len() == 1 | ||
&& parts[2].chars().next().unwrap().is_ascii_alphabetic() | ||
{ | ||
let mut windows_path = format!("{}:\\", parts[2].to_uppercase()); | ||
for part in &parts[3..] { | ||
if !part.is_empty() { | ||
windows_path.push_str(part); | ||
windows_path.push('\\'); | ||
} | ||
} | ||
windows_path | ||
} else { | ||
format!("wsl$/{distro_name}{abs_path}") | ||
} | ||
} else { | ||
format!("wsl$/{distro_name}{abs_path}") | ||
} | ||
} else { | ||
abs_path | ||
}; |
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.
I'd prefer if this code was written in a less nested way, the level of indentation makes it hard to read.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following the discussion in #913 ,
This solution supports both types of paths, Linux and Windows mounted.
When a path is under /mnt/{drive_letter}, it constructs the equivalent Windows path. Otherwise, the path is simply prefixed to indicate WSL.