Change logging

This commit is contained in:
Vansh Nath 2025-04-10 22:34:37 +02:00
parent d651cc30e3
commit 7480fcdf16
No known key found for this signature in database
GPG Key ID: 709BF3EAFB217A96
2 changed files with 7 additions and 8 deletions

View File

@ -103,19 +103,19 @@ impl<T: Completer> Completer for CustomCompletion<T> {
{ {
completion_options.case_sensitive = case_sensitive; 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 if let Some(algorithm) = options
.get("completion_algorithm") .get("completion_algorithm")
.and_then(|option| option.coerce_string().ok()) .and_then(|option| option.coerce_string().ok())
.and_then(|option| option.try_into().ok()) .and_then(|option| option.try_into().ok())
{ {
completion_options.match_algorithm = algorithm; completion_options.match_algorithm = algorithm;
if let Some(positional) = if let Some(false) = positional {
options.get("positional").and_then(|val| val.as_bool().ok()) if completion_options.match_algorithm == MatchAlgorithm::Prefix {
{
log::warn!("Use of the positional option is deprecated. Use the substring match algorithm instead.");
if !positional
&& completion_options.match_algorithm == MatchAlgorithm::Prefix
{
completion_options.match_algorithm = MatchAlgorithm::Substring completion_options.match_algorithm = MatchAlgorithm::Substring
} }
} }

View File

@ -234,7 +234,6 @@ fn customcompletions_override_options() {
&["Foo Abcdef", "Abcdef", "Acd Bar"], &["Foo Abcdef", "Abcdef", "Acd Bar"],
); );
// positional: false should make it do substring matching
// sort: true should force sorting // sort: true should force sorting
let expected: Vec<_> = vec!["Abcdef", "Foo Abcdef"]; let expected: Vec<_> = vec!["Abcdef", "Foo Abcdef"];
let suggestions = completer.complete("my-command Abcd", 15); let suggestions = completer.complete("my-command Abcd", 15);