Normalize line in picker preview to avoid crash
commit2d35b7b99cc903bc254e9e98979b7638c16d0e7a
authorDmitry Sharshakov <d3dx12.xx@gmail.com>
dateSun 5 Sep 2021, 14:31 (5 years ago)
parentb6c58ea
helix-term/src/ui/picker.rs+1
@@ -124,6 +124,7 @@ impl<T: 'static> Component for FilePicker<T> {
124124 }) {
125125 // align to middle
126126 let first_line = line
127+ .map(|(s, e)| (s.min(doc.text().len_lines()), e.min(doc.text().len_lines())))
127128 .map(|(start, _)| start)
128129 .unwrap_or(0)
129130 .saturating_sub(inner.height as usize / 2);