diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index 6124ce3f1b..2b788b019b 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -91,20 +91,21 @@ fn complete_rec( want_directory, isdir, )); - // For https://github.com/nushell/nushell/issues/13204 - if options.match_algorithm == MatchAlgorithm::Prefix { - let exact_match = if options.case_sensitive { - entry_name.eq(base) - } else { - entry_name.to_folded_case().eq(&base.to_folded_case()) - }; - if exact_match { - break; - } - } } else { completions.push(built); } + + // For https://github.com/nushell/nushell/issues/13204 + if isdir && options.match_algorithm == MatchAlgorithm::Prefix { + let exact_match = if options.case_sensitive { + entry_name.eq(base) + } else { + entry_name.to_folded_case().eq(&base.to_folded_case()) + }; + if exact_match { + break; + } + } } None => { completions.push(built); diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index b0559c78e5..159a8b5c07 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -1310,14 +1310,6 @@ fn exact_match() { &vec![file(dir.join("partial").join("hello.txt"))], &suggestions, ); - - let target_dir = format!("open {}", file(dir.join("pArTiAL").join("hello"))); - let suggestions = completer.complete(&target_dir, target_dir.len()); - - match_suggestions( - &vec![file(dir.join("partial").join("hello.txt"))], - &suggestions, - ); } #[ignore = "was reverted, still needs fixing"]