diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index 587f498b0a2..3bb70e0e1a3 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -727,10 +727,32 @@ impl<'t> TextEdit<'t> { // if there's a ScrollArea, it can properly scroll to the cursor. 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(), - ); + match ui.layout().main_dir() { + crate::Direction::LeftToRight | crate::Direction::TopDown => { + ui.allocate_rect( + Rect::from_min_size(outer_rect.max, extra_size), + Sense::hover(), + ); + } + crate::Direction::RightToLeft => { + ui.allocate_rect( + Rect::from_min_size( + emath::pos2(outer_rect.min.x - extra_size.x, outer_rect.max.y), + extra_size, + ), + Sense::hover(), + ); + } + crate::Direction::BottomUp => { + ui.allocate_rect( + Rect::from_min_size( + emath::pos2(outer_rect.min.x, outer_rect.max.y - extra_size.y), + extra_size, + ), + Sense::hover(), + ); + } + } } painter.galley(galley_pos, galley.clone(), text_color);