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 <emil.ernerfeldt@gmail.com>
This commit is contained in:
Barugon 2022-07-03 06:43:22 -07:00 committed by GitHub
parent cb9bc8698d
commit 433719717a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -610,7 +610,8 @@ impl<'t> TextEdit<'t> {
&cursor_range.primary, &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 ui.scroll_to_rect(cursor_pos, None); // keep cursor in view
} }