pub fn auto_wrap_break(
line: &str,
cursor_byte: usize,
cfg: ReflowConfig<'_>,
) -> Option<AutoWrapBreak>Expand description
Decide whether the line the cursor sits on should break, and where (§9).
Called on the keystroke path, once per inserted character, so it is a single scan of the current line and nothing else. No tree, no buffer walk, no allocation beyond the replacement string on the rare frame that actually breaks.
Returns None — leave the line alone — when:
- the cursor has not passed
textwidthyet; - there is no whitespace to break at after the prefix, i.e. the overlong thing is one word. Vim, Emacs and Rewrap all agree that a long URL overflows rather than being split;
- the only break points are past the margin, so breaking would not help.