From b1e74d4fdab802ed51fb1fe4f7930e95c14a1281 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 7 Mar 2024 11:28:41 -0800 Subject: [PATCH] default terminal width, height --- readline/buffer.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/readline/buffer.go b/readline/buffer.go index 7ccb1916..52e8a56c 100644 --- a/readline/buffer.go +++ b/readline/buffer.go @@ -19,10 +19,9 @@ type Buffer struct { func NewBuffer(prompt *Prompt) (*Buffer, error) { fd := int(os.Stdout.Fd()) - width, height, err := term.GetSize(fd) - if err != nil { - fmt.Println("Error getting size:", err) - return nil, err + width, height := 80, 24 + if termWidth, termHeight, err := term.GetSize(fd); err == nil { + width, height = termWidth, termHeight } lwidth := width - len(prompt.prompt())