Skip to content

Commit

Permalink
add test for ansi highlight underline, fix underscore in plain
Browse files Browse the repository at this point in the history
  • Loading branch information
mdibaiee committed Feb 7, 2022
1 parent 0bbdddf commit 57adeac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ impl<'a> Printer for InteractivePrinter<'a> {

if highlight_this_line && self.config.theme == "ansi" {
self.ansi_style.update("^[24m");
write!(handle, "\x1B[24m")?;
}

Ok(())
Expand Down
19 changes: 19 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,25 @@ fn grid_for_file_without_newline() {
.stderr("");
}

// For ANSI theme, use underscore as a highlighter
#[test]
fn ansi_highlight_underline() {
bat()
.arg("--paging=never")
.arg("--color=never")
.arg("--terminal-width=80")
.arg("--wrap=never")
.arg("--decorations=always")
.arg("--theme=ansi")
.arg("--style=plain")
.arg("--highlight-line=1")
.write_stdin("Ansi Underscore Test\nAnother Line")
.assert()
.success()
.stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line")
.stderr("");
}

// Ensure that ANSI passthrough is emitted properly for both wrapping and non-wrapping printer.
#[test]
fn ansi_passthrough_emit() {
Expand Down

0 comments on commit 57adeac

Please sign in to comment.