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

This commit is contained in:
三咲雅 · Misaki Masa 2024-04-25 16:39:44 +08:00 committed by GitHub
parent 8456d3a7dc
commit 1a3565963c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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)]

View File

@ -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::*;