From 9aba96604bf04cc73e115d24ba8a785e5978a6fc Mon Sep 17 00:00:00 2001 From: Yash Thakur <45539777+ysthakur@users.noreply.github.com> Date: Sun, 30 Mar 2025 23:41:42 -0400 Subject: [PATCH] Revert "Improve completions for exact matches (Issue #14794)" (#15457) Reverts nushell/nushell#15387 As pointed out by @132ikl in https://github.com/nushell/nushell/pull/15387#issuecomment-2764852850, #15387 had the unintended side effect of not showing all suggestions in certain cases when that wasn't desired. --- crates/nu-cli/src/completions/completion_common.rs | 2 +- crates/nu-cli/tests/completions/mod.rs | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index 3b9313ad37..c40a57527b 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -98,7 +98,7 @@ fn complete_rec( } // For https://github.com/nushell/nushell/issues/13204 - if options.match_algorithm == MatchAlgorithm::Prefix { + if isdir && options.match_algorithm == MatchAlgorithm::Prefix { let exact_match = if options.case_sensitive { entry_name.eq(base) } else { diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index efd561f3aa..10a207b88c 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -2224,16 +2224,6 @@ fn exact_match() { &vec![file(dir.join("partial").join("hello.txt")).as_str()], &suggestions, ); - - let target_dir = format!("open {}", file(dir.join("partial").join("hello"))); // No trailing slash - let suggestions = completer.complete(&target_dir, target_dir.len()); - - // Despite no trailing slash, since it's an exact match, only 'partial/hello.txt' should be suggested, not - // 'partial-a/hello' and stuff. See issue #14794 for details. - match_suggestions( - &vec![file(dir.join("partial").join("hello.txt")).as_str()], - &suggestions, - ); } #[ignore = "was reverted, still needs fixing"]