Debian Codegraph @

helix-core/src/wrap.rs

raw symbols SCIP
1 use smartstring::{LazyCompact, SmartString};
2 use textwrap::{Options, WordSplitter::NoHyphenation};
3
4 /// Given a slice of text, return the text re-wrapped to fit it
5 /// within the given width.
6 pub fn reflow_hard_wrap(text: &str, text_width: usize) -> SmartString<LazyCompact> {
7 let options = Options::new(text_width)
8 .word_splitter(NoHyphenation)
9 .word_separator(textwrap::WordSeparator::AsciiSpace);
10 textwrap::refill(text, options).into()
11 }