Skip to content

Commit e891a49

Browse files
committed
fix: use sum of scores in And engine
1 parent 0bf6e8f commit e891a49

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/engine/andor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl AndEngine {
8282
ranges.extend(vec.iter().copied());
8383
}
8484
}
85-
rank.score = rank.score.max(item.rank.score);
85+
rank.score = rank.score.saturating_add(item.rank.score);
8686
rank.begin = rank.begin.min(item.rank.begin);
8787
rank.end = rank.end.max(item.rank.end);
8888
}

src/fuzzy_matcher/arinae/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(super) const GAP_OPEN: Score = 6;
2121
/// Cost to extend a gap by one more character.
2222
pub(super) const GAP_EXTEND: Score = 2;
2323

24-
pub(super) const TYPO_PENALTY: Score = 8;
24+
pub(super) const TYPO_PENALTY: Score = 10;
2525

2626
/// Penalty for aligning a pattern char to a different choice char (typos only).
2727
pub(super) const MISMATCH_PENALTY: Score = 16;

src/fuzzy_matcher/arinae/tests.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,10 @@ fn typo_prefilter_no_false_negative_on_extension() {
396396
fn use_last_match_prefers_later_occurrence() {
397397
// "man/man1/sk.1" contains "man" at indices 0..=2 and again at 4..=6.
398398
// With use_last_match=true, the matcher should highlight the second one.
399-
let mut m = ArinaeMatcher::default();
400-
m.use_last_match = true;
399+
let m = ArinaeMatcher {
400+
use_last_match: true,
401+
..Default::default()
402+
};
401403
let (_, got) = m.fuzzy_indices("man/man1/sk.1", "man").expect("should match");
402404
assert_eq!(got, vec![4, 5, 6], "expected second 'man' (indices 4,5,6), got {got:?}");
403405
}

src/item.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ impl RankBuilder {
5353
/// Computes the byte offset of the first character after the last path separator
5454
/// (`/` or `\`) in `text`. Returns `0` when no separator is present.
5555
fn path_name_offset(text: &str) -> i32 {
56-
text.rfind(|c| c == '/' || c == '\\')
57-
.map(|pos| pos as i32 + 1)
58-
.unwrap_or(0)
56+
text.rfind(['/', '\\']).map(|pos| pos as i32 + 1).unwrap_or(0)
5957
}
6058

6159
/// Builds a `Rank` from raw match measurements.

tests/snapshots/matcher__matcher_arinae_typos.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
source: tests/matcher.rs
33
expression: buf + & cursor_pos
44
---
5-
" src/manpage.rs "
65
" src/util.rs "
6+
" src/skim_item.rs "
77
" src/item.rs "
88
" src/fuzzy_matcher/clangd.rs "
99
" src/fuzzy_matcher/frizbee.rs "
@@ -24,6 +24,6 @@ expression: buf + & cursor_pos
2424
" src/tui/util.rs "
2525
" src/tui/item_list.rs "
2626
"> src/tui/mod.rs "
27-
" 38/49 0/0"
27+
" 39/49 0/0"
2828
"> stum "
2929
cursor: (24, 7)

0 commit comments

Comments
 (0)