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.
This commit is contained in:
Tim Culverhouse 2024-05-06 19:03:07 -05:00
parent 920e490e4c
commit 48a8aa509c

View file

@ -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) {