From 78ebdb37b97945d1da6d47091b1325443d011e4f Mon Sep 17 00:00:00 2001 From: diegostafa Date: Sun, 4 Feb 2024 07:44:27 +0100 Subject: [PATCH 1/2] fix division by zero --- helix-term/src/ui/prompt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 702a6e6714ad..755b77c951f3 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -401,7 +401,7 @@ impl Prompt { let offset = self .selection - .map(|selection| selection / items * items) + .map(|selection| selection / std::cmp::max(1, items * items)) .unwrap_or_default(); surface.clear_with(area, background); From a02169c737c0e7a07d8d2b73d3499675385fc873 Mon Sep 17 00:00:00 2001 From: diegostafa Date: Tue, 6 Feb 2024 04:00:41 +0100 Subject: [PATCH 2/2] skip the popup rendering when there's no space --- helix-term/src/ui/prompt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 755b77c951f3..3764bba60c64 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -393,7 +393,7 @@ impl Prompt { height, ); - if !self.completion.is_empty() { + if completion_area.height > 0 && !self.completion.is_empty() { let area = completion_area; let background = theme.get("ui.menu"); @@ -401,7 +401,7 @@ impl Prompt { let offset = self .selection - .map(|selection| selection / std::cmp::max(1, items * items)) + .map(|selection| selection / items * items) .unwrap_or_default(); surface.clear_with(area, background);