ssh/terminal: fix GetSize on Windows

Return window size instead of buffer size.

Fixes golang/go#27743

Change-Id: Ib1cd249f5680d86d505032e51d9102c2718ddf6f
Reviewed-on: https://go-review.googlesource.com/c/163538
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Max Semenik 2019-02-23 00:20:48 -08:00 коммит произвёл Brad Fitzpatrick
Родитель 1fb3bd0768
Коммит 3fba1d1f88
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -64,13 +64,15 @@ func Restore(fd int, state *State) error {
return windows.SetConsoleMode(windows.Handle(fd), state.mode)
}
// GetSize returns the dimensions of the given terminal.
// GetSize returns the visible dimensions of the given terminal.
//
// These dimensions don't include any scrollback buffer height.
func GetSize(fd int) (width, height int, err error) {
var info windows.ConsoleScreenBufferInfo
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
return 0, 0, err
}
return int(info.Size.X), int(info.Size.Y), nil
return int(info.Window.Right - info.Window.Left + 1), int(info.Window.Bottom - info.Window.Top + 1), nil
}
// ReadPassword reads a line of input from a terminal without local echo. This