From 864656bd11d4f96235408e026f7ac68d86995919 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Tue, 21 Apr 2020 18:01:18 +0200 Subject: [PATCH] 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 --- src/output.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/output.rs b/src/output.rs index 15f29e43..0cfed062 100644 --- a/src/output.rs +++ b/src/output.rs @@ -86,11 +86,16 @@ impl OutputType { // versions of 'less'. Unfortunately, it also breaks mouse-wheel support. // // See: http://www.greenwoodsoftware.com/less/news.530.html + // + // For newer versions (530 or 558 on Windows), we omit '--no-init' as it + // is not needed anymore. match retrieve_less_version() { None => { p.arg("--no-init"); } - Some(version) if version < 530 => { + Some(version) + if (version < 530 || (cfg!(windows) && version < 558)) => + { p.arg("--no-init"); } _ => {}