@@ -7,6 +7,8 @@ use crate::error::*;
77use crate::less::retrieve_less_version;
88#[cfg(feature = "paging")]
99use crate::paging::PagingMode;
10+#[cfg(feature = "paging")]
11+use crate::wrapping::WrappingMode;
1012
1113#[derive(Debug)]
1214pub enum OutputType {
@@ -17,18 +19,23 @@ pub enum OutputType {
1719
1820impl OutputType {
1921 #[cfg(feature = "paging")]
20− pub fn from_mode(mode: PagingMode, pager: Option<&str>) -> Result<Self> {
22+ pub fn from_mode(paging_mode: PagingMode, wrapping_mode: WrappingMode, pager: Option<&str>) -> Result<Self> {
2123 use self::PagingMode::*;
22− Ok(match mode {
23− Always => OutputType::try_pager(false, pager)?,
24− QuitIfOneScreen => OutputType::try_pager(true, pager)?,
24+ use self::WrappingMode::*;
25+ Ok(match paging_mode {
26+ Always => OutputType::try_pager(false, wrapping_mode == Character, pager)?,
27+ QuitIfOneScreen => OutputType::try_pager(true, wrapping_mode == Character, pager)?,
2528 _ => OutputType::stdout(),
2629 })
2730 }
2831
2932 /// Try to launch the pager. Fall back to stdout in case of errors.
3033 #[cfg(feature = "paging")]
31− fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> {
34+ fn try_pager(
35+ quit_if_one_screen: bool,
36+ line_wrap: bool,
37+ pager_from_config: Option<&str>
38+ ) -> Result<Self> {
3239 use std::env;
3340 use std::ffi::OsString;
3441 use std::path::PathBuf;
@@ -82,6 +89,10 @@ impl OutputType {
8289 p.arg("--quit-if-one-screen");
8390 }
8491
92+ if !line_wrap {
93+ p.arg("-S");
94+ }
95+
8596 // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
8697 // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
8798 //