mirror of
https://github.com/nushell/nushell
synced 2024-12-27 21:43:09 +00:00
Remove "./" prefix for file path completions (#5387)
This commit is contained in:
parent
f16401152b
commit
07893e01c1
1 changed files with 9 additions and 1 deletions
|
@ -128,7 +128,11 @@ pub fn file_path_completion(
|
|||
entry.ok().and_then(|entry| {
|
||||
let mut file_name = entry.file_name().to_string_lossy().into_owned();
|
||||
if matches(&partial, &file_name, match_algorithm) {
|
||||
let mut path = format!("{}{}", base_dir_name, file_name);
|
||||
let mut path = if is_current_dir(&base_dir_name) {
|
||||
file_name.to_string()
|
||||
} else {
|
||||
format!("{}{}", base_dir_name, file_name)
|
||||
};
|
||||
if entry.path().is_dir() {
|
||||
path.push(SEP);
|
||||
file_name.push(SEP);
|
||||
|
@ -158,3 +162,7 @@ pub fn file_path_completion(
|
|||
pub fn matches(partial: &str, from: &str, match_algorithm: MatchAlgorithm) -> bool {
|
||||
match_algorithm.matches_str(&from.to_ascii_lowercase(), &partial.to_ascii_lowercase())
|
||||
}
|
||||
|
||||
fn is_current_dir(base_dir: &str) -> bool {
|
||||
base_dir == format!(".{}", SEP)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue