Skip to content

Commit f00fdf6

Browse files
committed
feat: stricter fuzzy search with gap penalties and score threshold
- penalize scattered matches (2 points per skipped char) - fail fast if token > target - enforce min score of 60/150 to reduce noise
1 parent d397269 commit f00fdf6

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project are documented in this file.
44

55
## [Unreleased]
66

7+
## [0.5.0] - 2026-02-21
8+
9+
### Changed
10+
11+
- **Stricter Fuzzy Search**: The search algorithm now penalizes scattered matches (large gaps between matched characters) and enforces a minimum quality score. This significantly reduces noise in search results, preventing irrelevant entries from appearing just because they contain the query letters widely separated.
12+
- Optimized search performance by failing fast when query tokens are longer than the target text.
13+
714
## [0.4.0] - 2026-02-21
815

916
### Added

Sources/CBManager/ClipboardSearch.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ enum ClipboardSearch {
8181

8282
private static func subsequenceScore(_ token: String, in target: String) -> Int? {
8383
guard !token.isEmpty else { return nil }
84+
// Optimization: if token is longer than target, fail immediately
85+
if token.count > target.count { return nil }
8486

8587
var tokenIndex = token.startIndex
8688
var targetIndex = target.startIndex
@@ -104,6 +106,10 @@ enum ClipboardSearch {
104106
}
105107
}
106108

107-
return max(1, 140 - min(gapPenalty, 120))
109+
// Stricter penalty: 2 points per skipped character.
110+
// Base score: 150.
111+
// Threshold: 60.
112+
let score = 150 - (gapPenalty * 2)
113+
return score > 60 ? score : nil
108114
}
109115
}

0 commit comments

Comments
 (0)