1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ---------------------------------------------------------------------------
// Scoring constants
// ---------------------------------------------------------------------------
use Score;
/// Points awarded for each correctly matched character.
pub const MATCH_BONUS: Score = 18;
/// Extra bonus when the match is at position 0 of the choice string.
pub const START_OF_STRING_BONUS: Score = 16;
/// Extra bonus for a camelCase transition.
pub const CAMEL_CASE_BONUS: Score = 6;
/// Bonus for each additional consecutive matched character.
pub const CONSECUTIVE_BONUS: Score = 11;
/// Cost to open a gap (skip characters in choice).
pub const GAP_OPEN: Score = 6;
/// Cost to extend a gap by one more character.
pub const GAP_EXTEND: Score = 4;
pub const TYPO_PENALTY: Score = 10;
/// Penalty for aligning a pattern char to a different choice char (typos only).
pub const MISMATCH_PENALTY: Score = 16;
/// Maximum pattern length supported by the banding arrays (stack-allocated).
pub const MAX_PAT_LEN: usize = 32;
/// Bandwidth for typo-mode banding. In typo mode we allow diagonal moves
/// (match/mismatch) plus UP (skip pattern char) and LEFT (skip choice char),
/// so the optimal path can wander off the main diagonal. A bandwidth of
/// `n + TYPO_BAND_SLACK` columns around the diagonal is generous enough
/// to capture all viable alignments while still pruning far-off cells.
pub const TYPO_BAND_SLACK: usize = 4;
/// Per-separator bonus lookup table. Each entry holds the `Score` awarded when
/// a matched character immediately follows that ASCII codepoint. Non-separator
/// characters (and all non-ASCII codepoints) map to `0`.
///
/// Different separators can carry different bonuses — for example, `/` and `\`
/// delimit path components (high bonus), while `_` or `-` delimit sub-words
/// (standard bonus). Entries that are `0` are not considered separators.
pub const SEPARATOR_TABLE: = ;