Skip to content

Commit 4e101d2

Browse files
authored
Fix textedit intrinsic size metric (#5275)
Since textedit is doing the justify layout calculation itself, we need to report the original desired_size as intrinsic size, instead of the value passed to allocate_space. I wonder though, is it still necessary that the TextEdit does the justify calculation itself instead of relying on the ui layout to do it? As far as I understand it, justify should be handled by the ui.allocate_space call.
1 parent 5b846b4 commit 4e101d2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crates/egui/src/widgets/text_edit/builder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,13 @@ impl<'t> TextEdit<'t> {
525525

526526
let mut galley = layouter(ui, text.as_str(), wrap_width);
527527

528-
let desired_width = if clip_text {
528+
let desired_inner_width = if clip_text {
529529
wrap_width // visual clipping with scroll in singleline input.
530530
} else {
531531
galley.size().x.max(wrap_width)
532532
};
533533
let desired_height = (desired_height_rows.at_least(1) as f32) * row_height;
534-
let desired_inner_size = vec2(desired_width, galley.size().y.max(desired_height));
534+
let desired_inner_size = vec2(desired_inner_width, galley.size().y.max(desired_height));
535535
let desired_outer_size = (desired_inner_size + margin.sum()).at_least(min_size);
536536
let (auto_id, outer_rect) = ui.allocate_space(desired_outer_size);
537537
let rect = outer_rect - margin; // inner rect (excluding frame/margin).
@@ -562,7 +562,7 @@ impl<'t> TextEdit<'t> {
562562
Sense::hover()
563563
};
564564
let mut response = ui.interact(outer_rect, id, sense);
565-
response.intrinsic_size = Some(desired_outer_size);
565+
response.intrinsic_size = Some(Vec2::new(desired_width, desired_outer_size.y));
566566

567567
response.fake_primary_click = false; // Don't sent `OutputEvent::Clicked` when a user presses the space bar
568568

0 commit comments

Comments
 (0)