-
Notifications
You must be signed in to change notification settings - Fork 9k
Description
Environment
Windows build number: Version 10.0.18362.295
Also tested with a recent commit 7faf334
Steps to reproduce
In a conhost WSL shell, execute the following command:
echo -e "\e[6;19r\e[24H\e[99ACUU\e[1H\e[99BCUD\e[r"
This does the following:
- sets the top and bottom
DECSTBMmargins to 6 and 19 - moves to line 24 (i.e. below the bottom margin)
- executes the
CUUsequence with a count of 99, to move up 99 lines - writes out CUU
- moves to line 1 (i.e. above the top margin)
- executes the
CUDsequence with a count of 99, to move down 99 lines - writes out CUD
Expected behavior
Quoting from the DEC STD 070 manual:
If the Active Position is at or below the Top Margin when the CUU control is executed, and an attempt is made to move the Active Position above the Top Margin, the control will be executed until the Active Position reaches the Top Margin. The Active Position will not move beyond the Top Margin.
Similarly for the CUD command:
If the Active Position is at or above the Bottom Margin when the CUD control is executed, and an attempt is made to move the Active Position below the Bottom Margin, the control will be executed until the Active Position reaches the Bottom Margin. The Active position will not move beyond the Bottom Margin.
So I would expect the CUU sequence to stop on line 6, the top margin, and the CUB sequence to stop on line 19, the bottom margin.
This is what the output looks like in XTerm:
Actual behavior
In the Windows console, the movement isn't constrained by the margins. As a result, the CUU sequences ends up at the top of the viewport, and the CUD sequences ends up at the bottom.
Note that this isn't a regression of #170. We do get it right if the initial cursor position was inside the margins. It's just when it starts off outside the margins that it's not being constrained.
The complication is that you sometimes don't want the cursor position constrained. For example, if you're moving up (with CUU), and you started off above the top margin, then there's no need to constrain the position below that margin.

