Skip to content

Commit

Permalink
fzf-v1: fix order of arguments of char_eq in debug assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Nov 12, 2023
1 parent a89917c commit 4b2cfb9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/algos/fzf/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ fn backward_pass(
) -> usize {
// The candidate must start with the first character of the query.
debug_assert!(char_eq(
pattern.chars().next().unwrap(),
candidate.chars().next().unwrap(),
pattern.chars().next().unwrap()
));

// The candidate must end with the last character of the query.
debug_assert!(char_eq(
pattern.chars().next_back().unwrap(),
candidate.chars().next_back().unwrap(),
pattern.chars().next_back().unwrap()
));

let mut pattern_chars = pattern.chars().rev();
Expand Down
14 changes: 14 additions & 0 deletions tests/fzf_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,17 @@ fn fzf_v1_score_4() {

assert_eq!(mach.matched_ranges(), [1..2, 21..22]);
}

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

let mut parser = FzfParser::new();

let mach = fzf.distance(parser.parse("e !"), " !I\\hh+\u{364}").unwrap();

assert_eq!(mach.matched_ranges(), [1..2, 7..9]);
}

0 comments on commit 4b2cfb9

Please sign in to comment.