Fix crash in goto_window_center at EOF (#5987)

This commit is contained in:
Pascal Kuthe 2023-02-14 20:00:54 +01:00 committed by GitHub
parent 0a7c697dd7
commit 715c4b24d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -960,10 +960,9 @@ fn goto_window(cx: &mut Context, align: Align) {
view.offset.vertical_offset + last_visual_line.saturating_sub(scrolloff + count)
}
};
let visual_line = visual_line.clamp(
view.offset.vertical_offset + scrolloff,
view.offset.vertical_offset + last_visual_line.saturating_sub(scrolloff),
);
let visual_line = visual_line
.max(view.offset.vertical_offset + scrolloff)
.min(view.offset.vertical_offset + last_visual_line.saturating_sub(scrolloff));
let pos = view
.pos_at_visual_coords(doc, visual_line as u16, 0, false)