Skip to content

Commit

Permalink
Revert "Fix off by one error in highlight (Xithrius#649)"
Browse files Browse the repository at this point in the history
This reverts commit 62f53e4.
  • Loading branch information
Nogesma committed Aug 13, 2024
1 parent 62f53e4 commit 71fd184
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
25 changes: 2 additions & 23 deletions Cargo.lock

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

11 changes: 4 additions & 7 deletions src/handlers/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,9 @@ impl MessageData {
) -> Vec<Span<'s>> {
static EMOTE_FINDER: Lazy<memmem::Finder> =
Lazy::new(|| memmem::Finder::new(ZERO_WIDTH_SPACE_STR));
let line_is_empty = line.is_empty();

// A line contains emotes if `emotes` is not empty and `line` starts with a unicode placeholder or contains ZWS.
let spans = if emotes.is_empty()
if emotes.is_empty()
|| (!line.starts_with(PRIVATE_USE_UNICODE)
&& EMOTE_FINDER.find(line.as_bytes()).is_none())
{
Expand Down Expand Up @@ -437,9 +436,7 @@ impl MessageData {

*start_index = start_index.saturating_sub(ZERO_WIDTH_SPACE_STR.len());
spans
};
*start_index += usize::from(!line_is_empty);
spans
}
}

pub fn to_vec(
Expand Down Expand Up @@ -849,7 +846,7 @@ mod tests {

assert_eq!(emotes, EMOTES_ID_PID);

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

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

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

assert_eq!(
spans,
Expand Down

0 comments on commit 71fd184

Please sign in to comment.