pub fn estimate_height(
msg: &Message,
params: &LayoutParams,
measure: &dyn TextMeasure,
) -> u32Expand description
Rough height for a row that has never been laid out.
Feeds the estimated heights in crate::index. Deliberately crude —
it only has to keep the scrollbar plausible until the row is actually
measured, and being fast matters more than being close, since it runs
for every row in the buffer on a resize.
Crude, but not low. The distinction matters because while the view
is following the bottom its scroll offset is total - viewport, and
the total is this estimate for every row that has not been laid out
yet — which always includes the row that was just appended. An
under-estimate therefore puts “the bottom” above the real bottom and
clips the newest message off the bottom edge. Over-estimating costs a
slightly wrong scrollbar thumb until the row is measured, which is
the tradeoff crate::index already documents.
Three things it has to get right for that, all of which it once got
wrong: a body’s hard newlines (dividing the byte length by the
column count answers “how far would this wrap”, not “how many lines
does it have”, so a five-line message estimated as one); the width
the body actually wraps against, which in indent mode is the content
width less the gutter; and the vertical padding a code or image block
adds. The avatar floor is the same rule layout_message applies at
the end.