diff --git a/tests/examples/regression_tests/issue_2541.txt b/tests/examples/regression_tests/issue_2541.txt new file mode 100644 index 0000000000..1059b94ec6 --- /dev/null +++ b/tests/examples/regression_tests/issue_2541.txt @@ -0,0 +1 @@ +]8;;http://example.com\This is a link]8;;\n \ No newline at end of file diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 6194828036..f8fde0de63 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1,6 +1,7 @@ use predicates::boolean::PredicateBooleanExt; use predicates::{prelude::predicate, str::PredicateStrExt}; use serial_test::serial; +use std::io::BufRead; use std::path::Path; use std::str::from_utf8; use tempfile::tempdir; @@ -1067,6 +1068,22 @@ fn bom_stripped_when_no_color_and_not_loop_through() { ); } +// Regression test for https://github.com/sharkdp/bat/issues/2541 +#[test] +fn no_broken_osc_emit_with_line_wrapping() { + bat() + .arg("--color=always") + .arg("--decorations=never") + .arg("--wrap=character") + .arg("--terminal-width=40") + .arg("regression_tests/issue_2541.txt") + .assert() + .success() + .stdout( + predicate::function(|s: &str| s.lines().count() == 1) + ); +} + #[test] fn can_print_file_named_cache() { bat_with_config()