summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan P <eth-p+git@hidden.email>2023-04-17 17:27:08 -0700
committerEthan P. <eth-p+git@hidden.email>2024-02-09 22:09:39 -0800
commit2d46d54ae351045b220abbb88e81eb3dbee9376f (patch)
tree989d2776a059150deb77d4abeb52d195ff169c59
parent3d04699710540840b36ab964a7bce3597322fa88 (diff)
Add tests for re-emitting SGR sequences on wrap
-rw-r--r--tests/integration_tests.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs
index 3b8bdf7f..d90e724b 100644
--- a/tests/integration_tests.rs
+++ b/tests/integration_tests.rs
@@ -1933,6 +1933,43 @@ fn ansi_passthrough_emit() {
}
}
+// Ensure that a simple ANSI sequence passthrough is emitted properly on wrapped lines.
+// This also helps ensure that escape sequences are counted as part of the visible characters when wrapping.
+#[test]
+fn ansi_sgr_emitted_when_wrapped() {
+ bat()
+ .arg("--paging=never")
+ .arg("--color=never")
+ .arg("--terminal-width=20")
+ .arg("--wrap=character")
+ .arg("--decorations=always")
+ .arg("--style=plain")
+ .write_stdin("\x1B[33mColor...............Also color.\n")
+ .assert()
+ .success()
+ .stdout("\x1B[33m\x1B[33mColor...............\n\x1B[33mAlso color.\n")
+ // FIXME: ~~~~~~~~ should not be emitted twice.
+ .stderr("");
+}
+
+// Ensure that multiple ANSI sequence SGR attributes are combined when emitted on wrapped lines.
+#[test]
+fn ansi_sgr_joins_attributes_when_wrapped() {
+ bat()
+ .arg("--paging=never")
+ .arg("--color=never")
+ .arg("--terminal-width=20")
+ .arg("--wrap=character")
+ .arg("--decorations=always")
+ .arg("--style=plain")
+ .write_stdin("\x1B[33mColor. \x1B[1mBold.........Also bold and color.\n")
+ .assert()
+ .success()
+ .stdout("\x1B[33m\x1B[33mColor. \x1B[1m\x1B[33m\x1B[1mBold.........\n\x1B[33m\x1B[1mAlso bold and color.\n")
+ // FIXME: ~~~~~~~~ ~~~~~~~~~~~~~~~ should not be emitted twice.
+ .stderr("");
+}
+
#[test]
fn ignored_suffix_arg() {
bat()