diff options
Diffstat (limited to 'src/modules/directory.rs')
-rw-r--r-- | src/modules/directory.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/modules/directory.rs b/src/modules/directory.rs index e0f4a9e12..710f73593 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -21,6 +21,7 @@ pub fn segment(context: &Context) -> Option<Module> { module.set_style(module_color); let current_dir = &context.current_dir; + log::debug!("Current directory: {:?}", current_dir); let dir_string; if let Some(repo_root) = &context.repo_root { @@ -58,7 +59,7 @@ fn contract_path(full_path: &Path, top_level_path: &Path, top_level_replacement: format!( "{replacement}{separator}{path}", replacement = top_level_replacement, - separator = std::path::MAIN_SEPARATOR, + separator = "/", path = full_path .strip_prefix(top_level_path) .unwrap() @@ -76,15 +77,13 @@ fn truncate(dir_string: String, length: usize) -> String { return dir_string; } - let components = dir_string - .split(std::path::MAIN_SEPARATOR) - .collect::<Vec<&str>>(); + let components = dir_string.split("/").collect::<Vec<&str>>(); if components.len() <= length { return dir_string; } let truncated_components = &components[components.len() - length..]; - truncated_components.join(&std::path::MAIN_SEPARATOR.to_string()) + truncated_components.join("/") } #[cfg(test)] |