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](0ecc94956b/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
This commit is contained in:
sharkdp 2020-04-21 18:01:18 +02:00
parent 2e9cf63a5f
commit 864656bd11

View file

@ -86,11 +86,16 @@ impl OutputType {
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support. // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
// //
// See: http://www.greenwoodsoftware.com/less/news.530.html // 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() { match retrieve_less_version() {
None => { None => {
p.arg("--no-init"); p.arg("--no-init");
} }
Some(version) if version < 530 => { Some(version)
if (version < 530 || (cfg!(windows) && version < 558)) =>
{
p.arg("--no-init"); p.arg("--no-init");
} }
_ => {} _ => {}