Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions resources/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if (odin_search) {
return x;
}


// matches one string against a pattern
function fuzzy_match(str, pattern) {
// Score consts
const ADJACENCY_BONUS = 5; // bonus for adjacent matches
Expand Down Expand Up @@ -101,7 +101,7 @@ if (odin_search) {

let matched_indices = [];

// Loop over strings
// Loop over string
while (str_idx != str_length) {
let pattern_char = pattern_idx != pattern_length ? pattern.charAt(pattern_idx) : null;
let str_char = str.charAt(str_idx);
Expand Down Expand Up @@ -183,7 +183,12 @@ if (odin_search) {
if (str_char == '.') {
seen_dot = true;
}

// Match separator
prev_separator = str_char == '_' || str_char == ' ' || str_char == '.';
if (prev_separator && !prev_matched) {
pattern_idx += 1
}

str_idx += 1;
}
Expand Down