From 88fcf87c53dc521a130a7c903a7248a420ae3126 Mon Sep 17 00:00:00 2001 From: qxxt <57898942+qxxt@users.noreply.github.com> Date: Tue, 27 Jun 2023 14:30:13 +0000 Subject: [PATCH] term: consistently return zeroes on GetSize error All other platform have return value of 0 for error when trying to get the terminal size while unix have -1. That makes it hard to catch whether the value passed from it was inserted on purpose. Change-Id: If47d07bd2d4f6cd439ad0ff4958e4095c8e4df9d GitHub-Last-Rev: 39cb14de33786844d097bc1d51bc667da8785ed9 GitHub-Pull-Request: golang/term#6 Reviewed-on: https://go-review.googlesource.com/c/term/+/506235 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov --- term_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/term_unix.go b/term_unix.go index a4e31ab..62c2b3f 100644 --- a/term_unix.go +++ b/term_unix.go @@ -60,7 +60,7 @@ func restore(fd int, state *State) error { func getSize(fd int) (width, height int, err error) { ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ) if err != nil { - return -1, -1, err + return 0, 0, err } return int(ws.Col), int(ws.Row), nil }