From 91f81f9625947d7a437f1f9f04105b800f5b2c2d Mon Sep 17 00:00:00 2001 From: nuid32 Date: Thu, 2 Mar 2023 09:02:58 +0000 Subject: [PATCH] Fix 'attempt to divide by zero' panic --- helix-term/src/ui/text.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/ui/text.rs b/helix-term/src/ui/text.rs index c318052b2dd0..a379536f8b62 100644 --- a/helix-term/src/ui/text.rs +++ b/helix-term/src/ui/text.rs @@ -58,7 +58,7 @@ pub fn required_size(text: &tui::text::Text, max_text_width: u16) -> (u16, u16) let content_width = content.width() as u16; if content_width > max_text_width { text_width = max_text_width; - height += content_width / max_text_width; + height += content_width.checked_div(max_text_width).unwrap_or(0); } else if content_width > text_width { text_width = content_width; }