Skip to content

Commit fd4d7a8

Browse files
ayn2opgdamore
authored andcommitted
fix(windows): remove incorrect +1 from console dimension calculations
The Windows Console API already returns the correct dimensions (0-based coordinates) Closes #889
1 parent 2c42625 commit fd4d7a8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tty_win.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ func (w *winTty) getConsoleInput() error {
216216

217217
case resizeEvent:
218218
w.Lock()
219-
w.cols = binary.LittleEndian.Uint16(ir.data[0:]) + 1
220-
w.rows = binary.LittleEndian.Uint16(ir.data[2:]) + 1
219+
w.cols = binary.LittleEndian.Uint16(ir.data[0:])
220+
w.rows = binary.LittleEndian.Uint16(ir.data[2:])
221221
cb := w.resizeCb
222222
w.Unlock()
223223
if cb != nil {
@@ -312,8 +312,8 @@ func NewDevTty() (Tty, error) {
312312
_, _, _ = procGetConsoleScreenBufferInfo.Call(uintptr(w.out), uintptr(unsafe.Pointer(&w.oscreen)))
313313
_, _, _ = procGetConsoleMode.Call(uintptr(w.out), uintptr(unsafe.Pointer(&w.oomode)))
314314
_, _, _ = procGetConsoleMode.Call(uintptr(w.in), uintptr(unsafe.Pointer(&w.oimode)))
315-
w.rows = uint16(w.oscreen.size.y + 1)
316-
w.cols = uint16(w.oscreen.size.x + 1)
315+
w.rows = uint16(w.oscreen.size.y)
316+
w.cols = uint16(w.oscreen.size.x)
317317

318318
return w, nil
319319
}

0 commit comments

Comments
 (0)