Skip to content

Commit de46bdb

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 (cherry picked from commit fd4d7a8)
1 parent ce18ca2 commit de46bdb

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
@@ -175,8 +175,8 @@ func (w *winTty) getConsoleInput() error {
175175

176176
case resizeEvent:
177177
w.Lock()
178-
w.cols = binary.LittleEndian.Uint16(ir.data[0:]) + 1
179-
w.rows = binary.LittleEndian.Uint16(ir.data[2:]) + 1
178+
w.cols = binary.LittleEndian.Uint16(ir.data[0:])
179+
w.rows = binary.LittleEndian.Uint16(ir.data[2:])
180180
cb := w.resizeCb
181181
w.Unlock()
182182
if cb != nil {
@@ -271,8 +271,8 @@ func NewDevTty() (Tty, error) {
271271
_, _, _ = procGetConsoleScreenBufferInfo.Call(uintptr(w.out), uintptr(unsafe.Pointer(&w.oscreen)))
272272
_, _, _ = procGetConsoleMode.Call(uintptr(w.out), uintptr(unsafe.Pointer(&w.oomode)))
273273
_, _, _ = procGetConsoleMode.Call(uintptr(w.in), uintptr(unsafe.Pointer(&w.oimode)))
274-
w.rows = uint16(w.oscreen.size.y + 1)
275-
w.cols = uint16(w.oscreen.size.x + 1)
274+
w.rows = uint16(w.oscreen.size.y)
275+
w.cols = uint16(w.oscreen.size.x)
276276

277277
return w, nil
278278
}

0 commit comments

Comments
 (0)