Skip to content

Commit

Permalink
Only update size when values are valid
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrewsun2898 authored Jul 12, 2023
1 parent e176cdf commit fbfcd0c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions getline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit fbfcd0c

Please sign in to comment.