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:
parent
920e490e4c
commit
48a8aa509c
1 changed files with 1 additions and 0 deletions
|
@ -131,6 +131,7 @@ fn widthToCursor(self: *TextInput, win: Window) usize {
|
||||||
|
|
||||||
pub fn draw(self: *TextInput, win: Window) void {
|
pub fn draw(self: *TextInput, win: Window) void {
|
||||||
if (self.cursor_idx < self.draw_offset) self.draw_offset = self.cursor_idx;
|
if (self.cursor_idx < self.draw_offset) self.draw_offset = self.cursor_idx;
|
||||||
|
if (win.width == 0) return;
|
||||||
while (true) {
|
while (true) {
|
||||||
const width = self.widthToCursor(win);
|
const width = self.widthToCursor(win);
|
||||||
if (width >= win.width) {
|
if (width >= win.width) {
|
||||||
|
|
Loading…
Reference in a new issue