Issue: screen buffer height limited to 9028 lines #5056

Closed
opened 2026-01-31 00:03:56 +00:00 by claunia · 1 comment
Owner

Originally created by @ffays on GitHub (Nov 18, 2019).

Description

When setting the screen buffer height, with the command mode con lines=32766 it appears that the maximum number of lines kept in the buffer are 9028 lines.

Would it be possible that the Windows Terminal to be at least backward compatible with both cmd.exe and powershell.exe consoles?

Environment

Windows build number: 10.0.18362.0
Windows Terminal version: 0.6.2951.0

Steps to reproduce

Using cmd.exe

mode con lines=32766 & powershell -Command "for($i=1;$i -le 32764;$i++){Write-Host $i}"

Using powershell.exe

mode con lines=32766; for($i=1;$i -le 32765;$i++){Write-Host $i}

Expected behavior

Expecting that line with number "1" to be shown at the very begining of the buffer.

Actual behavior

Using cmd.exe

First line of the buffer is number 23738

Using powershell.exe

First line of the buffer is number 23739

Post Scriptum

If you could go beyond the 32766 lines limit that ages from the 16 bit era, it will be fantastic (c.f. feature request #3612)!

Originally created by @ffays on GitHub (Nov 18, 2019). # Description When setting the screen buffer height, with the command `mode con lines=32766` it appears that the maximum number of lines kept in the buffer are 9028 lines. Would it be possible that the Windows Terminal to be at least backward compatible with both cmd.exe and powershell.exe consoles? # Environment Windows build number: 10.0.18362.0 Windows Terminal version: 0.6.2951.0 # Steps to reproduce ### Using cmd.exe ``` mode con lines=32766 & powershell -Command "for($i=1;$i -le 32764;$i++){Write-Host $i}" ``` ### Using powershell.exe ``` mode con lines=32766; for($i=1;$i -le 32765;$i++){Write-Host $i} ``` <!-- A description of how to trigger this bug. --> # Expected behavior Expecting that line with number "1" to be shown at the very begining of the buffer. # Actual behavior ### Using cmd.exe First line of the buffer is number 23738 ### Using powershell.exe First line of the buffer is number 23739 # Post Scriptum If you could go beyond the 32766 lines limit that ages from the 16 bit era, it will be fantastic (c.f. feature request #3612)!
Author
Owner

@zadjii-msft commented on GitHub (Nov 25, 2019):

So, I think this is one of those fundamental differences between a "console" and a "terminal" that we're not really going to be able to maintain compatibility with in the Terminal.

mode is a legacy application that was able to interact directly with the console's backing buffer. It's able to manually resize the console buffer to SHRT_MAX when you call mode con lines=32766. To do this, it uses the Windows Console APIs to resize the buffer.

However, the Terminal is a little different - it's built more like a *nix terminal, where there isn't the same concept of a "console buffer", instead there's just a "scrollback". In *nix, there's no way for a client application (like mode) to be able to resize the scrollback. In order to maintain compatibility with *nix applications, there's also no concept of a Console API in the terminal. Instead, *nix commandline applications us VT sequences, which are strings of characters, in order to manipulate the state of the terminal.

The Terminal uses a compatibility layer called "conpty" to be able to translate some Console API calls into roughly equivalent VT sequences, so the Terminal can behave just like a *nix terminal, but also work with many legacy Windows console applications. However, since it's not possible to resize the scrollback with VT, it's also not really possible to make this feature of mode work in the Windows Terminal (or any other terminal).

@zadjii-msft commented on GitHub (Nov 25, 2019): So, I think this is one of those fundamental differences between a "console" and a "terminal" that we're not really going to be able to maintain compatibility with in the Terminal. `mode` is a legacy application that was able to interact directly with the console's backing buffer. It's able to manually resize the console buffer to `SHRT_MAX` when you call `mode con lines=32766`. To do this, it uses the Windows Console APIs to resize the buffer. However, the Terminal is a little different - it's built more like a \*nix terminal, where there isn't the same concept of a "console buffer", instead there's just a "scrollback". In \*nix, there's no way for a client application (like `mode`) to be able to resize the scrollback. In order to maintain compatibility with \*nix applications, there's also no concept of a Console API in the terminal. Instead, \*nix commandline applications us VT sequences, which are strings of characters, in order to manipulate the state of the terminal. The Terminal uses a compatibility layer called "conpty" to be able to translate some Console API calls into roughly equivalent VT sequences, so the Terminal can behave just like a \*nix terminal, but also work with many legacy Windows console applications. However, since it's not possible to resize the scrollback with VT, it's also not really possible to make this feature of `mode` work in the Windows Terminal (or any other terminal).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5056