From 9620e27e4f440ce77e5388920648b5bdf892f932 Mon Sep 17 00:00:00 2001 From: Himadri Bhattacharjee Date: Sat, 23 Dec 2023 06:06:00 +0000 Subject: [PATCH] fix: prevent greedy matching of directory names (#11403) Fixes #11396 # Description If a directory name is an exact match, the completer stops greedily matching directories with the same prefix. # User-Facing Changes Completions should work as described in #11396. # Tests + Formatting # After Submitting --- crates/nu-cli/src/completions/completion_common.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/nu-cli/src/completions/completion_common.rs b/crates/nu-cli/src/completions/completion_common.rs index ec1300dad..dfbb55102 100644 --- a/crates/nu-cli/src/completions/completion_common.rs +++ b/crates/nu-cli/src/completions/completion_common.rs @@ -22,7 +22,10 @@ fn complete_rec( Some(base) if matches(base, &entry_name, options) => { let partial = &partial[1..]; if !partial.is_empty() || isdir { - completions.extend(complete_rec(partial, &path, options, dir, isdir)) + completions.extend(complete_rec(partial, &path, options, dir, isdir)); + if entry_name.eq(base) { + break; + } } else { completions.push(path) }