Add tests for re-emitting SGR sequences on wrap

This commit is contained in:
Ethan P 2023-04-17 17:27:08 -07:00 committed by Ethan P.
parent 3d04699710
commit 2d46d54ae3
No known key found for this signature in database
GPG Key ID: 1BA2A0CC7C22B854

View File

@ -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()