From 2d46d54ae351045b220abbb88e81eb3dbee9376f Mon Sep 17 00:00:00 2001 From: Ethan P Date: Mon, 17 Apr 2023 17:27:08 -0700 Subject: [PATCH] Add tests for re-emitting SGR sequences on wrap --- tests/integration_tests.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) 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()