Skip to content

Commit 31a3858

Browse files
MaxSembradfitz
authored andcommitted
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 <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 215aa80 commit 31a3858

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: ssh/terminal/util_windows.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ func Restore(fd int, state *State) error {
6464
return windows.SetConsoleMode(windows.Handle(fd), state.mode)
6565
}
6666

67-
// GetSize returns the dimensions of the given terminal.
67+
// GetSize returns the visible dimensions of the given terminal.
68+
//
69+
// These dimensions don't include any scrollback buffer height.
6870
func GetSize(fd int) (width, height int, err error) {
6971
var info windows.ConsoleScreenBufferInfo
7072
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
7173
return 0, 0, err
7274
}
73-
return int(info.Size.X), int(info.Size.Y), nil
75+
return int(info.Window.Right - info.Window.Left + 1), int(info.Window.Bottom - info.Window.Top + 1), nil
7476
}
7577

7678
// ReadPassword reads a line of input from a terminal without local echo. This

0 commit comments

Comments
 (0)