Normalize line in picker preview to avoid crash

imgbot
Dmitry Sharshakov 3 years ago
parent b6c58ea23e
commit 2d35b7b99c
No known key found for this signature in database
GPG Key ID: 471FD32E15FD8473

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

Loading…
Cancel
Save