mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 04:26:13 +02:00
Substring Match Algorithm (#15511)
<!-- if this PR closes one or more issues, you can automatically link the PR with them by using one of the [*linking keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword), e.g. - this PR should close #xxxx - fixes #xxxx you can also mention related issues, PRs or discussions! --> # Description <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> This PR should close #15474 . # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> When users set the match algorithm to 'substring' by modifying `$env.config` to `$env.config.completions.algorithm = "substring"``), completions are done based on substring matches. This was previously possible by setting `positional` to be false in custom completers, but doing so now logs a warning as this feature is set to be deprecated and replaced by the new way of setting the matching algorithm to substring based.
This commit is contained in:
@@ -6,6 +6,7 @@ use crate::engine::Closure;
|
||||
pub enum CompletionAlgorithm {
|
||||
#[default]
|
||||
Prefix,
|
||||
Substring,
|
||||
Fuzzy,
|
||||
}
|
||||
|
||||
@@ -15,8 +16,9 @@ impl FromStr for CompletionAlgorithm {
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.to_ascii_lowercase().as_str() {
|
||||
"prefix" => Ok(Self::Prefix),
|
||||
"substring" => Ok(Self::Substring),
|
||||
"fuzzy" => Ok(Self::Fuzzy),
|
||||
_ => Err("'prefix' or 'fuzzy'"),
|
||||
_ => Err("'prefix' or 'fuzzy' or 'substring'"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user