Fix crash when too many completions available
Refs #81
commit83723957fe8a1f4b87b4590fc64dce941e162637
authorBlaž Hrastnik <blaz@mxxn.io>
dateTue 8 Jun 2021, 21:58 (5 years ago)
parentae51065
helix-term/src/ui/prompt.rs+4−1
@@ -127,7 +127,10 @@ impl Prompt {
127127 // completion
128128
129129 let max_col = std::cmp::max(1, area.width / BASE_WIDTH);
130− let height = ((self.completion.len() as u16 + max_col - 1) / max_col);
130+ let height = ((self.completion.len() as u16 + max_col - 1) / max_col)
131+ .min(10) // at most 10 rows (or less)
132+ .min(area.height);
133+
131134 let completion_area = Rect::new(
132135 area.x,
133136 (area.height - height).saturating_sub(1),