Skip to content

Commit

Permalink
fzf-v2: don't reset the penalty at GAP_START after last match in a row
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Nov 22, 2023
1 parent 0bc5f98 commit fbf0c6b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/algos/fzf/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ fn score_first_row(

let mut column = 0;

let mut penalty;
let mut penalty = penalty::GAP_START;

for char_offset in candidate.matches(first_pattern_char) {
penalty = penalty::GAP_START;
Expand Down Expand Up @@ -366,8 +366,6 @@ fn score_first_row(
prev_score = score;
}

penalty = penalty::GAP_START;

for col in column + 1..scores_first_row.len() {
let score = prev_score.saturating_sub(penalty);
scores_first_row[col] = score;
Expand Down Expand Up @@ -405,7 +403,7 @@ fn score_remaining_rows(

let mut column = first_match_offset;

let mut penalty;
let mut penalty = penalty::GAP_START;

for char_offset in
candidate.matches_from(first_match_offset, pattern_char)
Expand Down Expand Up @@ -458,8 +456,6 @@ fn score_remaining_rows(
scores_row[column] = score;
}

penalty = penalty::GAP_START;

for col in column + 1..matrix_width {
let score_left = scores_row[col - 1];
let score = score_left.saturating_sub(penalty);
Expand Down

0 comments on commit fbf0c6b

Please sign in to comment.