Skip to content

Commit

Permalink
fix find_last_unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Nov 12, 2023
1 parent 61bff9c commit ae2137d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ fn find_last_unicode(
) -> Option<(usize, char)> {
haystack
.char_indices()
.rev()
.find_map(|(offset, ch)| char_eq(needle, ch).then_some((offset, ch)))
}

Expand Down
16 changes: 15 additions & 1 deletion tests/fzf_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
mod fzf_common;

use fzf_common as common;
use norm::fzf::FzfV1;
use norm::fzf::{FzfParser, FzfV1};
use norm::{CaseSensitivity, Metric};

#[test]
fn fzf_v1_upstream_empty() {
Expand Down Expand Up @@ -214,3 +215,16 @@ fn fzf_v1_upstream_suffix_5() {
fn fzf_v1_upstream_suffix_6() {
common::upstream_suffix_6::<FzfV1>()
}

#[test]
fn fzf_v1_score_1() {
let mut fzf = FzfV1::new()
.with_case_sensitivity(CaseSensitivity::Sensitive)
.with_matched_ranges(true);

let mut parser = FzfParser::new();

let mach = fzf.distance(parser.parse("ZZ"), "ӥZZZ").unwrap();

assert_eq!(mach.matched_ranges(), [2..4]);
}

0 comments on commit ae2137d

Please sign in to comment.