-
Notifications
You must be signed in to change notification settings - Fork 9k
Description
Environment
Windows build number: Version 10.0.18362.356
Steps to reproduce
Open a WSL shell in conhost and execute the following command:
printf "\ec\e[1;15r\e[3g\e[1;20H\eH\e[?25l\e[9;20H\e[?1049hstart\r\e[99Bmargin\e[H\ttab\n"
This initialises a number of terminal properties.
- The scrolling margins are set to 1:15 (
DECSTBM). - The tabstops are cleared and then a single tabstop is set at column 20 (
TBC/HTS). - The cursor blinking is disabled (
DECTCEM). - The cursor position is set to line 9 column 20 (
CUP).
It then switches to the alternate screen buffer (private mode 1049) and "tests" the state.
- The text "start" is output to indicate the starting position.
- The cursor is moved down 99 lines (
CUD), and the text "margin" is output to indicate the bottom margin position. - The cursor is moved to the home position (
CUP) and a tab is output, followed by the text "tab" to indicate the position of the tab stop.
Expected behavior
I would expect all of the initial state to be inherited by the alt buffer, producing the following results:
- The "start" text should be on line 9, column 20, i.e. the position before the switch to the alt buffer.
- The "margin" text should be on line 15, the bottom margin.
- The "tab" text should be in column 20, the position of the tab stop that was set.
- The cursor should be invisible.
Here's what the output looks like in XTerm:
Actual behavior
When switching to the alt buffer in conhost, we reset all those properties, producing the following results:
- The "start" text is in the top left corner.
- The "margin" text is at the bottom of the screen.
- The "tab" text is in column 9.
- The cursor is visible.
Here's what our output looks like:
The reason for this behaviour is because these properties are part of the SCREEN_INFORMATION class, and the alternate buffer is implemented as a separate instance of that class, when it should really be sharing much of that state with the main buffer.
The scroll margins are a little more complicated, since those properties are also duplicated in the AdaptDispatch class. And this can result in some weirdness when switching to the alt buffer since the two sets of values can end up out of sync.

