Skip to content

Commit

Permalink
Restore TextArea size fix, conditional on !clip_text
Browse files Browse the repository at this point in the history
  • Loading branch information
IaVashik committed Jan 27, 2025
1 parent 903a88d commit 3a030d7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use emath::Rect;
use epaint::text::{cursor::CCursor, Galley, LayoutJob};

use crate::{
Expand Down Expand Up @@ -722,6 +723,19 @@ impl TextEdit<'_> {
}
}

if !clip_text {
// Allocate additional space if edits were made this frame that changed the size. This is important so that,
// if there's a ScrollArea, it can properly scroll to the cursor.
// Condition `!clip_text` is important to avoid breaking layout for `TextEdit::singleline` (PR #5640)
let extra_size = galley.size() - rect.size();
if extra_size.x > 0.0 || extra_size.y > 0.0 {
ui.allocate_rect(
Rect::from_min_size(outer_rect.max, extra_size),
Sense::hover(),
);
}
}

painter.galley(galley_pos, galley.clone(), text_color);

if has_focus {
Expand Down

0 comments on commit 3a030d7

Please sign in to comment.