mirror of
https://github.com/nushell/nushell.git
synced 2025-06-10 20:16:48 +02:00
Remove positional from CompleteOptions
This commit is contained in:
parent
48347f38bb
commit
6bed42b0cf
@ -124,11 +124,7 @@ impl<T> NuMatcher<'_, T> {
|
||||
} else {
|
||||
Cow::Owned(haystack.to_folded_case())
|
||||
};
|
||||
let matches = if self.options.positional {
|
||||
haystack_folded.starts_with(self.needle.as_str())
|
||||
} else {
|
||||
haystack_folded.contains(self.needle.as_str())
|
||||
};
|
||||
let matches = haystack_folded.starts_with(self.needle.as_str());
|
||||
if matches {
|
||||
if let Some(item) = item {
|
||||
items.push((haystack.to_string(), item));
|
||||
@ -282,7 +278,6 @@ impl std::error::Error for InvalidMatchAlgorithm {}
|
||||
#[derive(Clone)]
|
||||
pub struct CompletionOptions {
|
||||
pub case_sensitive: bool,
|
||||
pub positional: bool,
|
||||
pub match_algorithm: MatchAlgorithm,
|
||||
pub sort: CompletionSort,
|
||||
}
|
||||
@ -291,7 +286,6 @@ impl Default for CompletionOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
case_sensitive: true,
|
||||
positional: true,
|
||||
match_algorithm: MatchAlgorithm::Prefix,
|
||||
sort: Default::default(),
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::completions::{
|
||||
completer::map_value_completions, Completer, CompletionOptions, SemanticSuggestion,
|
||||
completer::map_value_completions, Completer, CompletionOptions, MatchAlgorithm,
|
||||
SemanticSuggestion,
|
||||
};
|
||||
use nu_engine::eval_call;
|
||||
use nu_protocol::{
|
||||
@ -102,18 +103,22 @@ impl<T: Completer> Completer for CustomCompletion<T> {
|
||||
{
|
||||
completion_options.case_sensitive = case_sensitive;
|
||||
}
|
||||
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.");
|
||||
completion_options.positional = positional;
|
||||
}
|
||||
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())
|
||||
{
|
||||
if !positional
|
||||
&& completion_options.match_algorithm == MatchAlgorithm::Prefix
|
||||
{
|
||||
log::warn!("Use of the positional option is deprecated. Use the substring match algorithm instead.");
|
||||
completion_options.match_algorithm = MatchAlgorithm::Substring
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,8 +228,7 @@ fn customcompletions_override_options() {
|
||||
let mut completer = custom_completer_with_options(
|
||||
r#"$env.config.completions.algorithm = "fuzzy"
|
||||
$env.config.completions.case_sensitive = false"#,
|
||||
r#"completion_algorithm: "prefix",
|
||||
positional: false,
|
||||
r#"completion_algorithm: "substring",
|
||||
case_sensitive: true,
|
||||
sort: true"#,
|
||||
&["Foo Abcdef", "Abcdef", "Acd Bar"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user