A multi-line text taller than its part reports itself as a scroll region inside the part; drop the capped-field print

This commit is contained in:
Martin Ball
2026-11-18 16:36:00 +00:00
parent 679441e046
commit 82de1dbb9d
2 changed files with 7 additions and 6 deletions
@@ -228,6 +228,13 @@ pub(crate) fn show(ui: &mut Ui, edit: Edit<'_>) -> Shown {
}
shown
};
// A multi-line text taller than its part scrolls inside it: the part is the view, and the text, which the clip
// above cuts to the view, the content (S-L186: the text adapter owns the offset).
if multiline && galley.is_none() && output.response.rect.height() > rect.height() {
let text_rect = egui::Rect::from_min_size(output.galley_pos, output.galley.rect.size());
let content = placed.union(output.response.rect).union(text_rect);
super::widgets::note_scroll_region(ui.ctx(), rect.intersect(ui.clip_rect()), content);
}
let focused = output.response.has_focus();
let caret = output.cursor_range.map(|range| {
let at = output.galley.pos_from_cursor(range.primary);
-6
View File
@@ -328,12 +328,6 @@ impl<C: Codec + Clone + 'static> Component for TextField<'_, C> {
let tall = cx.layout(&TextRun::new(shown).role(self.options.role).wrap(Wrap::Wrap)).size().y;
let rows = if line > 0.0 { (tall / line).round() as usize } else { 1 };
size.y = size.y.max(height(lines.max(rows)));
if self.max_lines.is_some() {
eprintln!(
"DIAG a_capped_field_grows_to_its_lines_then_scrolls_with_the_caret_in_view: measure line={line} tall={tall} rows={rows} room={:?} size_y={}",
cx.room, size.y
);
}
if let Some(most) = self.max_lines {
size.y = size.y.min(height(most.max(lines)));
}