From c0e38aea7a3ecc845370e7b7ec7dd04faa2a5ced Mon Sep 17 00:00:00 2001 From: Dylan Bulfin Date: Thu, 15 Dec 2022 10:51:13 -0500 Subject: [PATCH 1/3] Bug fix Updated bug fix --- helix-term/src/ui/mod.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 107e48dd1ca3..0682400a050c 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -468,14 +468,23 @@ pub mod completers { let (dir, file_name) = if input.ends_with(std::path::MAIN_SEPARATOR) { (path, None) } else { - let file_name = path - .file_name() - .and_then(|file| file.to_str().map(|path| path.to_owned())); - - let path = match path.parent() { - Some(path) if !path.as_os_str().is_empty() => path.to_path_buf(), - // Path::new("h")'s parent is Some("")... - _ => std::env::current_dir().expect("couldn't determine current directory"), + let is_period = (input.ends_with("/.") && input.len() > 2) + || (input.starts_with('.') && input.len() == 1); + let file_name = if is_period { + Some(String::from(".")) + } else { + path.file_name() + .and_then(|file| file.to_str().map(|path| path.to_owned())) + }; + + let path = if is_period { + path + } else { + match path.parent() { + Some(path) if !path.as_os_str().is_empty() => path.to_path_buf(), + // Path::new("h")'s parent is Some("")... + _ => std::env::current_dir().expect("couldn't determine current directory"), + } }; (path, file_name) From e74567f9a50ac38f75a084a23545033de8cec2e2 Mon Sep 17 00:00:00 2001 From: Dylan Bulfin Date: Sat, 17 Dec 2022 17:52:12 -0500 Subject: [PATCH 2/3] Simplified conditionals --- helix-term/src/ui/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 0682400a050c..56f13be1302b 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -462,14 +462,13 @@ pub mod completers { use ignore::WalkBuilder; use std::path::Path; - let is_tilde = input.starts_with('~') && input.len() == 1; + let is_tilde = input == "~"; let path = helix_core::path::expand_tilde(Path::new(input)); let (dir, file_name) = if input.ends_with(std::path::MAIN_SEPARATOR) { (path, None) } else { - let is_period = (input.ends_with("/.") && input.len() > 2) - || (input.starts_with('.') && input.len() == 1); + let is_period = (input.ends_with("/.") && input.len() > 2) || input == "."; let file_name = if is_period { Some(String::from(".")) } else { From 1313902b64c5b89127e40b9dfc6daffeb8517e9d Mon Sep 17 00:00:00 2001 From: Dylan Bulfin Date: Thu, 22 Dec 2022 16:22:54 -0500 Subject: [PATCH 3/3] Switched to use path separator constant --- helix-term/src/ui/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index 56f13be1302b..0e4203fb3cc7 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -468,7 +468,9 @@ pub mod completers { let (dir, file_name) = if input.ends_with(std::path::MAIN_SEPARATOR) { (path, None) } else { - let is_period = (input.ends_with("/.") && input.len() > 2) || input == "."; + let is_period = (input.ends_with((format!("{}.", std::path::MAIN_SEPARATOR)).as_str()) + && input.len() > 2) + || input == "."; let file_name = if is_period { Some(String::from(".")) } else {