1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-05 19:11:42 +00:00

Only strip overstrike when a syntax highlighting theme is used

This commit is contained in:
Alex Kirk
2025-12-09 10:17:15 +01:00
parent 5fb8a25c30
commit 64a4b204a2
5 changed files with 80 additions and 15 deletions
+40
View File
@@ -2541,6 +2541,46 @@ fn binary_as_text() {
.stderr("");
}
#[test]
fn no_strip_overstrike_for_plain_text() {
// Overstrike is preserved for plain text files (no syntax highlighting)
bat()
.arg("--color=never")
.arg("--decorations=never")
.arg("overstrike.txt")
.assert()
.success()
.stdout("B\x08Bold t\x08te\x08ex\x08xt\x08t and _\x08u_\x08n_\x08d_\x08e_\x08r_\x08l_\x08i_\x08n_\x08e\n")
.stderr("");
}
#[test]
fn strip_overstrike_with_syntax_highlighting() {
// Overstrike is stripped when syntax highlighting is applied (e.g., for help)
bat()
.arg("--force-colorization")
.arg("--language=help")
.arg("overstrike.txt")
.assert()
.success()
.stdout(predicate::str::contains("Bold text and underline"))
.stderr("");
}
#[test]
fn strip_overstrike_for_manpage_syntax() {
// Overstrike is stripped for .man files (Manpage syntax)
bat()
.arg("--force-colorization")
.arg("git-commit.man")
.assert()
.success()
.stdout(predicate::str::contains("NAME"))
.stdout(predicate::str::contains("git-commit - Record changes"))
.stdout(predicate::str::is_match(r"\x1b\[38;[0-9;]+m--interactive\x1b\[").unwrap())
.stderr("");
}
#[test]
fn no_paging_arg() {
bat()