aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorDmitry Sharshakov2021-09-05 11:31:16 +0000
committerDmitry Sharshakov2021-09-05 11:31:16 +0000
commit2d35b7b99cc903bc254e9e98979b7638c16d0e7a (patch)
tree9a8ce50c8c805cc7199dc8794fbf97089c925de7 /helix-term/src
parentb6c58ea23e5970aef0247c5f3f05970de52a758f (diff)
Normalize line in picker preview to avoid crash
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/ui/picker.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index 090ba242..84b8dd72 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -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);