Skip postprocessing for short composer input (#39744)

## What changed

Return the initial wrapping ranges directly when the composer input produces a
single line and its byte length is less than the available width. This avoids
the additional grapheme and word-boundary pass for input that cannot wrap.

GitOrigin-RevId: 55d990a354fcc61e9a90d5796b4b39d16742cc50
This commit is contained in:
Benjamin Carlsson
2026-08-20 16:43:51 +00:00
committed by copyberry
parent 4f38432d87
commit c3db180493

View File

@@ -56,7 +56,7 @@ pub(super) fn wrapped_lines(text: &str, width: u16) -> Vec<Range<usize>> {
let width = usize::from(width);
let options = Options::new(width).wrap_algorithm(textwrap::WrapAlgorithm::FirstFit);
let wrapped_lines = crate::wrapping::wrap_ranges(text, &options);
if width == 0 {
if width == 0 || (wrapped_lines.len() == 1 && text.len() < width) {
return wrapped_lines;
}