From 48a8aa509cfc68e69119ce9d0e9ef8092f0c3158 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 6 May 2024 19:03:07 -0500 Subject: [PATCH] widgets(text_input): protect against zero-width window A zero-width window could set the text_input.draw method into an infinite loop. Explicitly protect against this case. --- src/widgets/TextInput.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/TextInput.zig b/src/widgets/TextInput.zig index 03421d2..dda137d 100644 --- a/src/widgets/TextInput.zig +++ b/src/widgets/TextInput.zig @@ -131,6 +131,7 @@ fn widthToCursor(self: *TextInput, win: Window) usize { pub fn draw(self: *TextInput, win: Window) void { if (self.cursor_idx < self.draw_offset) self.draw_offset = self.cursor_idx; + if (win.width == 0) return; while (true) { const width = self.widthToCursor(win); if (width >= win.width) {