diff --git a/crates/nu-cli/src/completions/custom_completions.rs b/crates/nu-cli/src/completions/custom_completions.rs index ac1345c093..072034fe7c 100644 --- a/crates/nu-cli/src/completions/custom_completions.rs +++ b/crates/nu-cli/src/completions/custom_completions.rs @@ -103,19 +103,19 @@ impl Completer for CustomCompletion { { completion_options.case_sensitive = case_sensitive; } + let positional = + options.get("positional").and_then(|val| val.as_bool().ok()); + if let Some(_positional) = positional { + log::warn!("Use of the positional option is deprecated. Use the substring match algorithm instead."); + } if let Some(algorithm) = options .get("completion_algorithm") .and_then(|option| option.coerce_string().ok()) .and_then(|option| option.try_into().ok()) { completion_options.match_algorithm = algorithm; - if let Some(positional) = - options.get("positional").and_then(|val| val.as_bool().ok()) - { - log::warn!("Use of the positional option is deprecated. Use the substring match algorithm instead."); - if !positional - && completion_options.match_algorithm == MatchAlgorithm::Prefix - { + if let Some(false) = positional { + if completion_options.match_algorithm == MatchAlgorithm::Prefix { completion_options.match_algorithm = MatchAlgorithm::Substring } } diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index eb8de0778c..8aba4337a8 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -234,7 +234,6 @@ fn customcompletions_override_options() { &["Foo Abcdef", "Abcdef", "Acd Bar"], ); - // positional: false should make it do substring matching // sort: true should force sorting let expected: Vec<_> = vec!["Abcdef", "Foo Abcdef"]; let suggestions = completer.complete("my-command Abcd", 15);