Skip to content

Commit

Permalink
fix: A overlooked bug in span impl
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Jun 24, 2024
1 parent 56fdc8b commit bdac6f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 10 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@
// {
buildInputs = [];
nativeBuildInputs = [];
packages = with pkgs; [
cargo-nextest
cargo-criterion
cargo-outdated
cargo-llvm-cov
];
packages = with pkgs;
[
cargo-nextest
cargo-criterion
cargo-outdated
cargo-mutants
]
++ lib.optionals pkgs.stdenv.isLinux [
cargo-llvm-cov
];
});
}
);
Expand Down
10 changes: 5 additions & 5 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ fn span(last: Style) -> impl Fn(&[u8]) -> IResult<&[u8], Span<'static>, nom::err
let (s, style) = opt(style(last))(s)?;

#[cfg(feature = "simd")]
let (s, text) = map_res(take_while(|c| c != b'\x1b' | b'\n'), |t| {
let (s, text) = map_res(take_while(|c| c != b'\x1b' && c != b'\n'), |t| {
simdutf8::basic::from_utf8(t)
})(s)?;

#[cfg(not(feature = "simd"))]
let (s, text) = map_res(take_while(|c| c != b'\x1b' | b'\n'), |t| {
let (s, text) = map_res(take_while(|c| c != b'\x1b' && c != b'\n'), |t| {

Check warning on line 171 in src/parser.rs

View check run for this annotation

Codecov / codecov/patch

src/parser.rs#L171

Added line #L171 was not covered by tests
std::str::from_utf8(t)
})(s)?;

Expand All @@ -187,20 +187,20 @@ fn span_fast(last: Style) -> impl Fn(&[u8]) -> IResult<&[u8], Span<'_>, nom::err
let (s, style) = opt(style(last))(s)?;

#[cfg(feature = "simd")]
let (s, text) = map_res(take_while(|c| c != b'\x1b' | b'\n'), |t| {
let (s, text) = map_res(take_while(|c| c != b'\x1b' && c != b'\n'), |t| {
simdutf8::basic::from_utf8(t)
})(s)?;

#[cfg(not(feature = "simd"))]
let (s, text) = map_res(take_while(|c| c != b'\x1b' | b'\n'), |t| {
let (s, text) = map_res(take_while(|c| c != b'\x1b' && c != b'\n'), |t| {

Check warning on line 195 in src/parser.rs

View check run for this annotation

Codecov / codecov/patch

src/parser.rs#L195

Added line #L195 was not covered by tests
std::str::from_utf8(t)
})(s)?;

if let Some(style) = style.flatten() {
last = last.patch(style);
}

Ok((s, Span::styled(text.to_owned(), last)))
Ok((s, Span::styled(text, last)))
}
}

Expand Down

0 comments on commit bdac6f6

Please sign in to comment.