Normalize line in picker preview to avoid crash

This commit is contained in:
Dmitry Sharshakov 2021-09-05 14:31:16 +03:00
parent b6c58ea23e
commit 2d35b7b99c
No known key found for this signature in database
GPG key ID: 471FD32E15FD8473

View file

@ -124,6 +124,7 @@ impl<T: 'static> Component for FilePicker<T> {
}) { }) {
// align to middle // align to middle
let first_line = line let first_line = line
.map(|(s, e)| (s.min(doc.text().len_lines()), e.min(doc.text().len_lines())))
.map(|(start, _)| start) .map(|(start, _)| start)
.unwrap_or(0) .unwrap_or(0)
.saturating_sub(inner.height as usize / 2); .saturating_sub(inner.height as usize / 2);