-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fuzzy autocompletion of files bugs #12680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There is no need for to be rude and disrespectful. Please change the title of this issue to something that is more respectful to the nushell contributors. |
I concur on this: the fuzzy finder matches without taking into account the score often give very surprising results. As a temporary fix, I have replaced the fuzzy matching by a substring search akin to what I had in zsh. It stands between the diff --git a/crates/nu-cli/src/completions/completion_options.rs b/crates/nu-cli/src/completions/completion_options.rs
index a414aafed..c1eaf540c 100644
--- a/crates/nu-cli/src/completions/completion_options.rs
+++ b/crates/nu-cli/src/completions/completion_options.rs
@@ -1,6 +1,7 @@
use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher};
use nu_parser::trim_quotes_str;
use nu_protocol::CompletionAlgorithm;
+use std::borrow::Borrow;
use std::fmt::Display;
#[derive(Copy, Clone)]
@@ -33,10 +34,7 @@ impl MatchAlgorithm {
let needle = trim_quotes_str(needle);
match *self {
MatchAlgorithm::Prefix => haystack.starts_with(needle),
- MatchAlgorithm::Fuzzy => {
- let matcher = SkimMatcherV2::default();
- matcher.fuzzy_match(haystack, needle).is_some()
- }
+ MatchAlgorithm::Fuzzy => haystack.contains(needle),
}
}
@@ -46,10 +44,10 @@ impl MatchAlgorithm {
MatchAlgorithm::Prefix => haystack.starts_with(needle),
MatchAlgorithm::Fuzzy => {
let haystack_str = String::from_utf8_lossy(haystack);
+ let haystack_str: &str = haystack_str.borrow();
let needle_str = String::from_utf8_lossy(needle);
- let matcher = SkimMatcherV2::default();
- matcher.fuzzy_match(&haystack_str, &needle_str).is_some()
+ haystack_str.contains(&*needle_str)
}
}
} To properly fix the fuzzy matching, one needs to:
I think there would be also value in adding a |
@cpg314 Edit: |
From playing around with version |
The reproducible example panic is resolved by nushell/reedline#886 as shipped with #15310 But there remains a case for non-prefix matches that @ysthakur is trying to address with nushell/reedline#887 This is triggered if the file doesn't start with the searched for character e.g. touch æææa
open 'a<TAB> |
Describe the bug
Sorry for the vague title. This issue is several issues all related to the autocompletion of file names for commands:
.matches_str()
. The problem with this is that the matcher used (SkimMatcherV2 from the fuzzy_matcher crate) already does case insensitive matching even if you do not turn everything lower case. So as it currently stands "case sensitive" mode is case insensitive, and "case insensitive" mode is again case insensitive but offers worse matches. The latter is currently the default.How to reproduce
Expected behavior
ls | get name | input list --fuzzy
seems to do a good job on all account raised above. It orders its matches from most to least relevant, is correctly case-insensitive while still using the case for better matches, and does not panic on unicode, even with unicode inside the prompt string.It might be relevant that
input list --fuzzy
uses thefuzzy-select
crate instead of thefuzzy-matcher
crate, which use different matching engines under the hood and may be the cause of some of the differences.Screenshots
No response
Configuration
Additional context
No response
The text was updated successfully, but these errors were encountered: