mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-01 10:52:24 +01:00
Merge pull request #2309 from johnmatthiggins/master
Added -S flag for truncating long lines
This commit is contained in:
1
tests/examples/long-single-line.txt
vendored
Normal file
1
tests/examples/long-single-line.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz
|
@@ -1499,6 +1499,47 @@ fn ignored_suffix_arg() {
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
fn wrapping_test(wrap_flag: &str, expect_wrap: bool) {
|
||||
let expected = match expect_wrap {
|
||||
true =>
|
||||
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcde\nfghigklmnopqrstuvxyz\n",
|
||||
false =>
|
||||
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n",
|
||||
};
|
||||
|
||||
bat()
|
||||
.arg(wrap_flag)
|
||||
.arg("--style=rule")
|
||||
.arg("--color=never")
|
||||
.arg("--decorations=always")
|
||||
.arg("--terminal-width=80")
|
||||
.arg("long-single-line.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(expected.to_owned())
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_line_wrapping_when_set_to_never() {
|
||||
wrapping_test("--wrap=never", false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn line_wrapping_when_auto() {
|
||||
wrapping_test("--wrap=auto", true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_line_wrapping_with_s_flag() {
|
||||
wrapping_test("-S", false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_wrapping_with_chop_long_lines() {
|
||||
wrapping_test("--chop-long-lines", false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn highlighting_is_skipped_on_long_lines() {
|
||||
let expected = "\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() +
|
||||
|
Reference in New Issue
Block a user