summaryrefslogtreecommitdiff
path: root/helix-core/src/wrap.rs
blob: f32d6f4bc11dcc71cbb9b1975cce1ee2a2b804dd (plain) (blame)
1
2
3
4
5
6
7
8
9
use smartstring::{LazyCompact, SmartString};
use textwrap::{Options, WordSplitter::NoHyphenation};

/// Given a slice of text, return the text re-wrapped to fit it
/// within the given width.
pub fn reflow_hard_wrap(text: &str, text_width: usize) -> SmartString<LazyCompact> {
    let options = Options::new(text_width).word_splitter(NoHyphenation);
    textwrap::refill(text, options).into()
}