on master help sign in
Pass --no-init on Windows if less version < 559

We used to call `less` with ``` bash less --RAW-CONTROL-CHARS --quit-if-one-screen --no-init ``` We only passed `--no-init` because there was a bug with previous versions of `less` which required the use of `--no-init` in combination with `--quit-if-one-screen` to prevent this "no output" issue from happening. Since bat 0.13, [we omit the `--no-init` option](https://github.com/sharkdp/bat/blob/0ecc94956b88beed27ca13a130c8ba09f1a220d8/src/output.rs#L85-L97) if we can detect that the version of `less` is higher than or equal to 530. We did that because `--no-init` breaks mouse support and because [less 530 fixed the above-mentioned bug](http://www.greenwoodsoftware.com/less/news.530.html). However, it seems that this bug was *not* fixed on Windows! According to @gwsw, the issue should be fixed with less 559 on Windows. closes #887

commit864656bd11d4f96235408e026f7ac68d86995919 authorsharkdp <davidpeter@web.de> dateTue 21 Apr 2020, 18:01 (7 years ago) parent2e9cf63
1 file changed+6−1
src/output.rs+6−1
src/output.rs+6−1
@@ -86,11 +86,16 @@ impl OutputType {
8686 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
8787 //
8888 // See: http://www.greenwoodsoftware.com/less/news.530.html
89+ //
90+ // For newer versions (530 or 558 on Windows), we omit '--no-init' as it
91+ // is not needed anymore.
8992 match retrieve_less_version() {
9093 None => {
9194 p.arg("--no-init");
9295 }
93− Some(version) if version < 530 => {
96+ Some(version)
97+ if (version < 530 || (cfg!(windows) && version < 558)) =>
98+ {
9499 p.arg("--no-init");
95100 }
96101 _ => {}