diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index 8aae72b4f3..77ae165c73 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -1,3 +1,4 @@ +use super::MatchAlgorithm; use crate::{ completions::{matches, CompletionOptions}, SemanticSuggestion, @@ -5,6 +6,7 @@ use crate::{ use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher}; use nu_ansi_term::Style; use nu_engine::env_to_string; +use nu_path::dots::expand_ndots; use nu_path::{expand_to_real_path, home_dir}; use nu_protocol::{ engine::{EngineState, Stack, StateWorkingSet}, @@ -13,8 +15,6 @@ use nu_protocol::{ use nu_utils::get_ls_colors; use std::path::{is_separator, Component, Path, PathBuf, MAIN_SEPARATOR as SEP}; -use super::MatchAlgorithm; - #[derive(Clone, Default)] pub struct PathBuiltFromString { parts: Vec, @@ -41,7 +41,7 @@ pub fn complete_rec( let mut completions = vec![]; if let Some((&base, rest)) = partial.split_first() { - if (base == "." || base == "..") && (isdir || !rest.is_empty()) { + if base.chars().all(|c| c == '.') && (isdir || !rest.is_empty()) { let mut built = built.clone(); built.parts.push(base.to_string()); built.isdir = true; @@ -156,16 +156,25 @@ pub fn complete_item( engine_state: &EngineState, stack: &Stack, ) -> Vec<(nu_protocol::Span, String, Option