Skip to content

Commit

Permalink
Merge pull request #351 from ysndr/patch-2
Browse files Browse the repository at this point in the history
Allow `Doc` to `Display` impl to use defined width
  • Loading branch information
pacak authored Mar 22, 2024
2 parents 9088f7f + 12121c0 commit ca5fecf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod manpage;
mod splitter;

pub(crate) use self::console::Color;
use self::console::MAX_WIDTH;

#[cfg(feature = "docgen")]
pub use manpage::Section;
Expand Down Expand Up @@ -331,7 +332,8 @@ pub struct Doc {

impl std::fmt::Display for Doc {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.monochrome(true))
let width = f.width().unwrap_or(MAX_WIDTH);
f.write_str(&self.render_console(true, Color::Monochrome, width))
}
}

Expand Down

0 comments on commit ca5fecf

Please sign in to comment.