|
|
@ -463,20 +463,30 @@ pub mod completers {
|
|
|
|
use ignore::WalkBuilder;
|
|
|
|
use ignore::WalkBuilder;
|
|
|
|
use std::path::Path;
|
|
|
|
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 path = helix_core::path::expand_tilde(Path::new(input));
|
|
|
|
|
|
|
|
|
|
|
|
let (dir, file_name) = if input.ends_with(std::path::MAIN_SEPARATOR) {
|
|
|
|
let (dir, file_name) = if input.ends_with(std::path::MAIN_SEPARATOR) {
|
|
|
|
(path, None)
|
|
|
|
(path, None)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let file_name = path
|
|
|
|
let is_period = (input.ends_with((format!("{}.", std::path::MAIN_SEPARATOR)).as_str())
|
|
|
|
.file_name()
|
|
|
|
&& input.len() > 2)
|
|
|
|
.and_then(|file| file.to_str().map(|path| path.to_owned()));
|
|
|
|
|| input == ".";
|
|
|
|
|
|
|
|
let file_name = if is_period {
|
|
|
|
let path = match path.parent() {
|
|
|
|
Some(String::from("."))
|
|
|
|
Some(path) if !path.as_os_str().is_empty() => path.to_path_buf(),
|
|
|
|
} else {
|
|
|
|
// Path::new("h")'s parent is Some("")...
|
|
|
|
path.file_name()
|
|
|
|
_ => std::env::current_dir().expect("couldn't determine current directory"),
|
|
|
|
.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)
|
|
|
|
(path, file_name)
|
|
|
|