diff --git a/CHANGELOG.md b/CHANGELOG.md index 986e8a09..67332437 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # unreleased ## Features +- Implemented `-S` and `--chop-long-lines` flags as aliases for `--wrap=character`. See #2309 (@johnmatthiggins) ## Bugfixes diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs index eeaa7b39..75e5a063 100644 --- a/src/bin/bat/app.rs +++ b/src/bin/bat/app.rs @@ -175,7 +175,7 @@ impl App { _ => unreachable!("other values for --wrap are not allowed"), } } else { - WrappingMode::Character + WrappingMode::NoWrapping(true) } } else { // We don't have the tty width when piping to another program. diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 426f6171..c956bf5d 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -206,7 +206,7 @@ pub fn build_app(interactive_output: bool) -> Command<'static> { .long("chop-long-lines") .short('S') .takes_value(false) - .help("Truncate all lines longer than screen width. Alias for '--wrap=never'."), + .help("Truncate all lines longer than screen width. Alias for '--wrap=character'."), ) .arg( Arg::new("terminal-width") diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 3130f434..6417327f 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1501,17 +1501,12 @@ fn ignored_suffix_arg() { #[test] fn no_line_wrapping_when_set_to_never() { - let expected = -"───────┬──────────────────────────────────────────────────────────────────────── - │ File: 80-columns.txt - │ Size: 101 B -───────┼──────────────────────────────────────────────────────────────────────── - 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz -───────┴──────────────────────────────────────────────────────────────────────── + let expected = "abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz "; bat() - .arg("--style=full") + .arg("--style=rule") + .arg("--color=never") .arg("--decorations=always") .arg("--wrap=never") .arg("--terminal-width=80") @@ -1525,17 +1520,13 @@ fn no_line_wrapping_when_set_to_never() { #[test] fn line_wrapping_when_auto() { let expected = - "───────┬──────────────────────────────────────────────────────────────────────── - │ File: 80-columns.txt - │ Size: 101 B -───────┼──────────────────────────────────────────────────────────────────────── - 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu - │ vxyzabcdefghigklmnopqrstuvxyz -───────┴──────────────────────────────────────────────────────────────────────── + "abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcde +fghigklmnopqrstuvxyz "; bat() - .arg("--style=full") + .arg("--color=never") + .arg("--style=rule") .arg("--decorations=always") .arg("--wrap=auto") .arg("--terminal-width=80") @@ -1547,19 +1538,13 @@ fn line_wrapping_when_auto() { } #[test] -fn line_wrapping_with_s_flag() { +fn no_line_wrapping_with_s_flag() { let expected = - "───────┬──────────────────────────────────────────────────────────────────────── - │ File: 80-columns.txt - │ Size: 101 B -───────┼──────────────────────────────────────────────────────────────────────── - 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu - │ vxyzabcdefghigklmnopqrstuvxyz -───────┴──────────────────────────────────────────────────────────────────────── -"; + "abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n"; bat() - .arg("--style=full") + .arg("--color=never") + .arg("--style=rule") .arg("--decorations=always") .arg("-S") .arg("--terminal-width=80") @@ -1571,19 +1556,13 @@ fn line_wrapping_with_s_flag() { } #[test] -fn chop_long_lines_when_specified() { +fn no_wrapping_with_chop_long_lines() { let expected = - "───────┬──────────────────────────────────────────────────────────────────────── - │ File: 80-columns.txt - │ Size: 101 B -───────┼──────────────────────────────────────────────────────────────────────── - 1 │ abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstu - │ vxyzabcdefghigklmnopqrstuvxyz -───────┴──────────────────────────────────────────────────────────────────────── -"; + "abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n"; bat() - .arg("--style=full") + .arg("--color=never") + .arg("--style=rule") .arg("--decorations=always") .arg("--chop-long-lines") .arg("--terminal-width=80")