aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/mod.rs
diff options
context:
space:
mode:
authorDylan Bulfin2023-01-09 02:25:19 +0000
committerGitHub2023-01-09 02:25:19 +0000
commitc4b0eb835639d2c18d940cd0c55093a92169b432 (patch)
tree597fe6999b9cdbb2c3dd54962b74bc9d16f77619 /helix-term/src/ui/mod.rs
parentb368df57855c77be5f3ae6601f5a83b586feb7c3 (diff)
Fix autocompletion for paths with period (#5175)
* Bug fix Updated bug fix * Simplified conditionals * Switched to use path separator constant
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r--helix-term/src/ui/mod.rs28
1 files changed, 19 insertions, 9 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index ade1d8cf..eb480758 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -463,20 +463,30 @@ 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 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((format!("{}.", std::path::MAIN_SEPARATOR)).as_str())
+ && input.len() > 2)
+ || input == ".";
+ 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)