Skip to content

Commit

Permalink
Fix off by one error in highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
vesdev committed Aug 5, 2024
1 parent f8cfa57 commit 8e7dc17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
25 changes: 23 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/handlers/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl MessageData {
};

let offset = *start_index;
*start_index += line.len();
*start_index += line.len() + usize::from(!line.is_empty());

if HAS_NO_HIGHLIGHTS(search_highlight, &offset, start_index)
&& HAS_NO_HIGHLIGHTS(username_highlight, &offset, start_index)
Expand Down Expand Up @@ -846,7 +846,7 @@ mod tests {

assert_eq!(emotes, EMOTES_ID_PID);

assert_eq!(start_index, line.len());
assert_eq!(start_index - 1, line.len());

assert_eq!(
spans,
Expand Down Expand Up @@ -899,7 +899,7 @@ mod tests {
);

assert!(emotes.is_empty());
assert_eq!(start_index, line.len());
assert_eq!(start_index - 1, line.len());

assert_eq!(
spans,
Expand Down

0 comments on commit 8e7dc17

Please sign in to comment.