diff --git a/src/algos/fzf/scheme.rs b/src/algos/fzf/scheme.rs index 1604b30..6dd7efc 100644 --- a/src/algos/fzf/scheme.rs +++ b/src/algos/fzf/scheme.rs @@ -27,12 +27,13 @@ impl FzfScheme { } /// TODO: docs +#[doc(hidden)] #[derive(Clone)] -pub(super) struct Scheme { +pub struct Scheme { pub bonus_boundary_white: Score, pub bonus_boundary_delimiter: Score, - pub initial_char_class: CharClass, - pub is_delimiter: fn(char) -> bool, + pub(super) initial_char_class: CharClass, + pub(super) is_delimiter: fn(char) -> bool, } impl Default for Scheme { diff --git a/src/algos/fzf/v2.rs b/src/algos/fzf/v2.rs index 810efc1..21c63b3 100644 --- a/src/algos/fzf/v2.rs +++ b/src/algos/fzf/v2.rs @@ -27,6 +27,12 @@ impl FzfV2 { Self::default() } + /// TODO: docs + #[cfg(feature = "tests")] + pub fn scheme(&self) -> &Scheme { + &self.scheme + } + /// TODO: docs #[inline] pub fn with_case_sensitivity( @@ -315,11 +321,11 @@ where .zip(scoring_matrix.cols(left_of_starting_col)) .zip(scoring_matrix.cols(up_left_of_starting_col)); - let candidate = candidate.slice(matched_idx..last_matched_idx); - let mut is_in_gap = false; - for (char_idx, candidate_char) in candidate.char_idxs() { + for (char_idx, candidate_char) in + candidate.slice(matched_idx..last_matched_idx).char_idxs() + { let ((cell, left_cell), up_left_cell) = cols.next().unwrap(); let score_left = @@ -341,7 +347,7 @@ where if consecutive > 1 { let fb = bonus_vector[CandidateCharIdx( - char_idx.into_usize() - consecutive + 1, + char_idx.into_usize() + 1 - consecutive, )]; if bonus >= bonus::BOUNDARY && bonus > fb { diff --git a/tests/fzf_v2.rs b/tests/fzf_v2.rs index c6297f3..793edb5 100644 --- a/tests/fzf_v2.rs +++ b/tests/fzf_v2.rs @@ -23,9 +23,10 @@ fn fzf_v2_score_1() { assert_eq!( mach.distance().into_score(), - bonus::MATCH * 5 + bonus::CAMEL_123 - - penalty::GAP_START - - penalty::GAP_EXTENSION * 3 + bonus::MATCH * 5 + + fzf.scheme().bonus_boundary_white + * bonus::FIRST_QUERY_CHAR_MULTIPLIER + + fzf.scheme().bonus_boundary_white * 4 ); assert_eq!(mach.matched_ranges().sorted(), [0..5]);