helix-editor/nucleo

Panic with simple pattern.

markus-bauer opened this issue · 2 comments

I know you're still working on this. But I might as well report it.
The example below panics with 'should have been caught by prefilter', .../git/checkouts/nucleo-fe29e1ee969779b0/9c4b710/matcher/src/fuzzy_optimal.rs:41:13

Has something to do with case, because it doesn't happen when ignore_case is false.

[dependencies]
nucleo = {version ="*", git="https://github.com/helix-editor/nucleo"}
use nucleo::*;

fn main() {
    let conf = MatcherConfig::DEFAULT;
    let mut matcher = Matcher::new(conf);

    let needle = "aB";
    let mut buf1 = Vec::new();
    let needle = Utf32Str::new(needle, &mut buf1);

    let haystack = "aaB";
    let mut buf2 = Vec::new();
    let haystack = Utf32Str::new(haystack, &mut buf2);

    let mut indices = Vec::new();
    let result = matcher.fuzzy_indices(haystack, needle, &mut indices);

    println!("{:?} {:?}", result, indices);
}

This is expected if you are doing case insenstivie matching you most provide the needle as entirely lowercase. Everything else is an API missuse and the panic is intentional in that case. This still needs better docs. I would reccomend using the Pattern high level API for matching instead since that will care of stuff like this automatically

Okay, thanks. I just started playing around with this. I should have waited for a more official release.