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

feat: support expanding Windows paths like "D:" that only have a drive letter but no root #948

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ cargo publish -p yazi-config
cargo publish -p yazi-proxy
cargo publish -p yazi-adaptor
cargo publish -p yazi-boot
cargo publish -p yazi-dds
cargo publish -p yazi-scheduler
cargo publish -p yazi-plugin
cargo publish -p yazi-core
cargo publish -p yazi-fm
cargo publish -p yazi-cli
2 changes: 1 addition & 1 deletion yazi-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parking_lot = "0.12.1"
percent-encoding = "2.3.1"
ratatui = "=0.26.1"
regex = "1.10.4"
serde = "1.0.198"
serde = { version = "1.0.198", features = [ "derive" ] }
tokio = { version = "1.37.0", features = [ "full" ] }

# Logging
Expand Down
9 changes: 9 additions & 0 deletions yazi-shared/src/fs/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ fn _expand_path(p: &Path) -> PathBuf {
env::var(name.as_str()).unwrap_or_else(|_| caps.get(0).unwrap().as_str().to_owned())
});

// Windows paths that only have a drive letter but no root, e.g. "D:"
#[cfg(windows)]
if s.len() == 2 {
let b = s.as_bytes();
if b[1] == b':' && b[0].is_ascii_alphabetic() {
return PathBuf::from(s.to_uppercase() + "\\");
}
}

let p = Path::new(s.as_ref());
if let Ok(rest) = p.strip_prefix("~") {
#[cfg(unix)]
Expand Down
1 change: 1 addition & 0 deletions yazi-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub use errors::*;
pub use layer::*;
pub use natsort::*;
pub use number::*;
#[cfg(unix)]
pub use os::*;
pub use ro_cell::*;
pub use throttle::*;
Expand Down