@@ -82,11 +82,13 @@ impl OutputType {
82 p.arg("--quit-if-one-screen");
82 p.arg("--quit-if-one-screen");
85+ let less_version = retrieve_less_version();
85 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
87 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
86 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
88 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
88 // See: http://www.greenwoodsoftware.com/less/news.530.html
90 // See: http://www.greenwoodsoftware.com/less/news.530.html
89− match retrieve_less_version() {
91+ match less_version {
91 p.arg("--no-init");
93 p.arg("--no-init");
@@ -95,6 +97,16 @@ impl OutputType {
101+ // Passing '--mouse' allows mouse scrolling in terminals which do not
102+ // support "fake scrolling", see https://github.com/sharkdp/bat/issues/904
103+ // The '--mouse' argument is only supported in less 551 or higher.
104+ match less_version {
105+ Some(version) if version >= 551 => {
99 p.args(args);
111 p.args(args);