From 01c6850c70204df94be68fc81668a5e485e9ed53 Mon Sep 17 00:00:00 2001 From: uttarayan21 Date: Tue, 10 Sep 2024 13:26:05 +0530 Subject: [PATCH] fix: Add test case for issue #50 --- src/parser.rs | 2 +- tests/tests.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 34130fc..7e808d4 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -53,7 +53,7 @@ impl From for tui::style::Style { AnsiCode::Normal => { style = style .remove_modifier(Modifier::BOLD) - .remove_modifier(Modifier::DIM) + .remove_modifier(Modifier::DIM); } AnsiCode::Italic => style = style.add_modifier(Modifier::ITALIC), AnsiCode::Underline => style = style.add_modifier(Modifier::UNDERLINED), diff --git a/tests/tests.rs b/tests/tests.rs index 06167f6..58d8d31 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -3,7 +3,7 @@ use ansi_to_tui::IntoText; use pretty_assertions::assert_eq; use tui::style::Stylize; use tui::{ - style::{Color, Style}, + style::{Color, Modifier, Style}, text::{Line, Span, Text}, }; @@ -191,6 +191,17 @@ fn test_rgb() { } } +#[test] +fn test_reset_sequences() { + let bytes = "not, \x1b[1mbold\x1b[22m, not anymore".as_bytes().to_vec(); + let output = Text::from(Line::from(vec![ + Span::raw("not, "), + Span::raw("bold").bold(), + Span::raw(", not anymore").remove_modifier(Modifier::BOLD | Modifier::DIM), + ])); + test_both(bytes, output); +} + #[cfg(test)] #[track_caller] pub fn test_both(bytes: impl AsRef<[u8]>, other: Text) {