Skip to content

Commit

Permalink
term: consistently return zeroes on GetSize error
Browse files Browse the repository at this point in the history
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: 39cb14d
GitHub-Pull-Request: #6
Reviewed-on: https://go-review.googlesource.com/c/term/+/506235
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
  • Loading branch information
qxxt authored and gopherbot committed Jul 4, 2023
1 parent f6de4a1 commit 88fcf87
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion term_unix.go
Expand Up @@ -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
}
Expand Down

0 comments on commit 88fcf87

Please sign in to comment.