mirror of
https://github.com/nushell/nushell.git
synced 2025-08-17 23:59:50 +02:00
feat(completion): enable nucleo's prefer_prefix
option (#16183)
cc: @blindFS @ysthakur # Description Enable `nucleo`'s `prefer_prefix` configuration option. Ranks suggestions with matches closer to the start higher than suggestions that have matches further from the start. Example: suggestions based on `reverse`: <table> <tr> <td width=200>Before</td> <td width=200>After</td> </tr> <tr> <td> ``` bytes reverse polars reverse reverse str reverse ``` </td> <td> ``` reverse str reverse polars reverse bytes reverse ``` </td> </tr> </table> # User-Facing Changes More relevant suggestions with fuzzy matching algorithm. (`$env.config.completions.algorithm = "fuzzy"`) # Tests + Formatting We might want to add tests to make sure this option keeps working in the future. Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
This commit is contained in:
@@ -102,7 +102,11 @@ impl<T> NuMatcher<'_, T> {
|
|||||||
options,
|
options,
|
||||||
needle: needle.to_owned(),
|
needle: needle.to_owned(),
|
||||||
state: State::Fuzzy {
|
state: State::Fuzzy {
|
||||||
matcher: Matcher::new(Config::DEFAULT),
|
matcher: Matcher::new({
|
||||||
|
let mut cfg = Config::DEFAULT;
|
||||||
|
cfg.prefer_prefix = true;
|
||||||
|
cfg
|
||||||
|
}),
|
||||||
atom,
|
atom,
|
||||||
items: Vec::new(),
|
items: Vec::new(),
|
||||||
},
|
},
|
||||||
|
@@ -80,7 +80,11 @@ pub(crate) struct SymbolCache {
|
|||||||
impl SymbolCache {
|
impl SymbolCache {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
SymbolCache {
|
SymbolCache {
|
||||||
matcher: Matcher::new(Config::DEFAULT),
|
matcher: Matcher::new({
|
||||||
|
let mut cfg = Config::DEFAULT;
|
||||||
|
cfg.prefer_prefix = true;
|
||||||
|
cfg
|
||||||
|
}),
|
||||||
cache: BTreeMap::new(),
|
cache: BTreeMap::new(),
|
||||||
dirty_flags: BTreeMap::new(),
|
dirty_flags: BTreeMap::new(),
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user