aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-08 12:58:26 +0000
committerBlaž Hrastnik2021-06-08 12:58:26 +0000
commit83723957fe8a1f4b87b4590fc64dce941e162637 (patch)
tree81513ecd8f5b02920e4b6a2c5f05bbb58c928dda
parentae51065213c4dfc0072c9dfe384527faf34b54ff (diff)
Fix crash when too many completions available
Refs #81
-rw-r--r--helix-term/src/ui/prompt.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 5b074d01..8367b12c 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -127,7 +127,10 @@ impl Prompt {
// completion
let max_col = std::cmp::max(1, area.width / BASE_WIDTH);
- let height = ((self.completion.len() as u16 + max_col - 1) / max_col);
+ let height = ((self.completion.len() as u16 + max_col - 1) / max_col)
+ .min(10) // at most 10 rows (or less)
+ .min(area.height);
+
let completion_area = Rect::new(
area.x,
(area.height - height).saturating_sub(1),