From 605ae0c7edf639761ec262159c5040c9daeed8fb Mon Sep 17 00:00:00 2001 From: RndUsr123 <150948884+RndUsr123@users.noreply.github.com> Date: Wed, 25 Mar 2026 12:15:58 +0000 Subject: [PATCH] Better internal alignment --- crates/egui/src/widgets/text_edit/builder.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index ef668a02e..547254411 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -575,6 +575,11 @@ impl TextEdit<'_> { atoms.push_right(atom); } + // Push prefix to the left and enable alignment for the main text + if align.0[0] != Align::LEFT { + atoms.push_right(Atom::grow()); + } + if text.as_str().is_empty() && !hint_text.is_empty() { // Add hint_text (if any): let mut shrunk = any_shrink; @@ -598,9 +603,7 @@ impl TextEdit<'_> { first = false; } - // The hint text should be shown left top instead of centered (important for - // multi line text edits) - atoms.push_right(atom.atom_align(Align2::LEFT_TOP)); + atoms.push_right(atom); } // Calculate the empty galley, so it can be read later. The available width is @@ -647,8 +650,8 @@ impl TextEdit<'_> { ); } - // Ensure the suffix is always right-aligned - if !suffix.is_empty() { + // Push suffix to the right and enable alignment for the main text + if align.0[0] != Align::RIGHT { atoms.push_right(Atom::grow()); }