Fix bugs in autoscroll with 'fit' strategy (#2893)

This fixes a bug where text moved up and down by one pixel in the buffer
search query editor, while typing.

Release  notes:
* Fixed a bug where editors didn't auto-scroll when typing if all
cursors could not fit within the viewport.
This commit is contained in:
Max Brunsfeld 2023-08-25 16:36:33 -07:00 committed by GitHub
commit d6ffb68305
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 110 additions and 36 deletions

View file

@ -2177,14 +2177,11 @@ impl Element<Editor> for EditorElement {
scroll_height
.min(constraint.max_along(Axis::Vertical))
.max(constraint.min_along(Axis::Vertical))
.max(line_height)
.min(line_height * max_lines as f32),
)
} else if let EditorMode::SingleLine = snapshot.mode {
size.set_y(
line_height
.min(constraint.max_along(Axis::Vertical))
.max(constraint.min_along(Axis::Vertical)),
)
size.set_y(line_height.max(constraint.min_along(Axis::Vertical)))
} else if size.y().is_infinite() {
size.set_y(scroll_height);
}