From 433719717ad2d5315f7b22fef308c0729f649516 Mon Sep 17 00:00:00 2001 From: Barugon Date: Sun, 3 Jul 2022 06:43:22 -0700 Subject: [PATCH] Don't call scroll if TextEdit is fully in view (#1779) * Don't call scroll if TextEdit is fully in view * Explain why the new logic was added * cargo fmt Co-authored-by: Emil Ernerfeldt --- egui/src/widgets/text_edit/builder.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/egui/src/widgets/text_edit/builder.rs b/egui/src/widgets/text_edit/builder.rs index 7f1e1f00..e11c44d9 100644 --- a/egui/src/widgets/text_edit/builder.rs +++ b/egui/src/widgets/text_edit/builder.rs @@ -610,7 +610,8 @@ impl<'t> TextEdit<'t> { &cursor_range.primary, ); - if response.changed || selection_changed { + let is_fully_visible = ui.clip_rect().contains_rect(rect); // TODO: remove this HACK workaround for https://github.com/emilk/egui/issues/1531 + if (response.changed || selection_changed) && !is_fully_visible { ui.scroll_to_rect(cursor_pos, None); // keep cursor in view }