From ad9f51e5819041eb413cbf547eae88dc101b4cd6 Mon Sep 17 00:00:00 2001 From: ath3 Date: Mon, 27 Dec 2021 23:01:48 +0100 Subject: [PATCH] Convert Windows style path separator in completers to Unix style --- helix-term/src/ui/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 9e096311ff93a..4fbbc4c251c4d 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -313,7 +313,7 @@ pub mod completers { return None; } - //let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir()); + let is_dir = entry.file_type().map_or(false, |entry| entry.is_dir()); let path = entry.path(); let mut path = if is_tilde { @@ -331,7 +331,12 @@ pub mod completers { path.push(""); } - let path = path.to_str().unwrap().to_owned(); + let path = if cfg!(windows) && is_dir { + // Convert Windows style path separator to Unix style + path.to_str().unwrap().replace("\\", "/").to_owned() + } else { + path.to_str().unwrap().to_owned() + }; Some((end.clone(), Cow::from(path))) }) }) // TODO: unwrap or skip