From fbfcd0c1c0b2854d6f062de6f063ccdeb6060411 Mon Sep 17 00:00:00 2001 From: andrewsun2898 Date: Tue, 11 Jul 2023 19:16:33 -0700 Subject: [PATCH] Only update size when values are valid In some environments the ioctl call for window size will return 0x0, for instance in serial console setups. This causes the input to be truncated making it hard for users to see what they are typing. This performs a check to see if either width or height has a non-zero value before updating the size. --- getline.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/getline.go b/getline.go index 597ac99..dc53667 100644 --- a/getline.go +++ b/getline.go @@ -33,8 +33,9 @@ var _ tea.Model = (*Editor)(nil) func (m *Editor) Update(imsg tea.Msg) (tea.Model, tea.Cmd) { switch msg := imsg.(type) { case tea.WindowSizeMsg: - m.Model.SetSize(msg.Width, msg.Height) - + if msg.Width != 0 || msg.Height != 0 { + m.Model.SetSize(msg.Width, msg.Height) + } case editline.InputCompleteMsg: return m, tea.Quit }