deno icon indicating copy to clipboard operation
deno copied to clipboard

:bug:(WinOS) `Deno.consoleSize()` incorrectly returns console buffer size

Open rivy opened this issue 1 year ago • 0 comments

for all versions of deno since at least 1.21.0

Deno.consoleSize() is incorrectly returning the console buffer size instead of the console window size. This can be seen when using the usual console window (not 'Windows Terminal').

Screenshot 2024-05-17 135307

I hadn't noticed this issue earlier because I primarily use 'Windows Terminal' which maintains its own scrollback buffer and allocates a console screen buffer which is the same size as the console view window. Additionally, most allocated consoles only reserve extra lines for the screen buffer, not extra columns. And most uses only care about the column width of the screen. As a result, Deno.consoleSize() has been accidentally correct for the majority of users and cases, likely since inception (#6520).

The error is in runtime/ops/tty/rs:

https://github.com/denoland/deno/blob/d64921c1906ee1ac39230c16abe9ff8c546bd645/runtime/ops/tty.rs#L273-L276

It's an easy fix. I'll post a PR for the fix in a few minutes.

rivy avatar May 17 '24 20:05 rivy