Skip to content

Commit 587cbac

Browse files
authored
fix: Swap height and width for TTY size (#1161)
This was causing the TTY to be real wonky on Windows. It didn't seem to have an effect on Linux, but I suspect that's because of escape codes.
1 parent 0c9f27c commit 587cbac

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

agent/agent.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (a *agent) handleSSHSession(session ssh.Session) error {
333333
}
334334
go func() {
335335
for win := range windowSize {
336-
err = ptty.Resize(uint16(win.Width), uint16(win.Height))
336+
err = ptty.Resize(uint16(win.Height), uint16(win.Width))
337337
if err != nil {
338338
a.logger.Warn(context.Background(), "failed to resize tty", slog.Error(err))
339339
}

pty/pty.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type PTY interface {
2525
Input() io.ReadWriter
2626

2727
// Resize sets the size of the PTY.
28-
Resize(cols uint16, rows uint16) error
28+
Resize(height uint16, width uint16) error
2929
}
3030

3131
// New constructs a new Pty.

pty/pty_other.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func (p *otherPty) Output() io.ReadWriter {
4242
}
4343
}
4444

45-
func (p *otherPty) Resize(cols uint16, rows uint16) error {
45+
func (p *otherPty) Resize(height uint16, width uint16) error {
4646
p.mutex.Lock()
4747
defer p.mutex.Unlock()
4848
return pty.Setsize(p.pty, &pty.Winsize{
49-
Rows: rows,
50-
Cols: cols,
49+
Rows: width,
50+
Cols: height,
5151
})
5252
}
5353

pty/pty_windows.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ func (p *ptyWindows) Input() io.ReadWriter {
8181
}
8282
}
8383

84-
func (p *ptyWindows) Resize(cols uint16, rows uint16) error {
84+
func (p *ptyWindows) Resize(height uint16, width uint16) error {
8585
// Taken from: https://github.com/microsoft/hcsshim/blob/54a5ad86808d761e3e396aff3e2022840f39f9a8/internal/winapi/zsyscall_windows.go#L144
8686
ret, _, err := procResizePseudoConsole.Call(uintptr(p.console), uintptr(*((*uint32)(unsafe.Pointer(&windows.Coord{
87-
X: int16(rows),
88-
Y: int16(cols),
87+
Y: int16(height),
88+
X: int16(width),
8989
})))))
9090
if ret != 0 {
9191
return err

0 commit comments

Comments
 (0)