Repository navigation
Description
This issue tracks implementing delayed EOL wrap for Terminal::_WriteBuffer. More details on the exact issue below.
This is a subset of or step towards #780.
The problem is just that the Terminal::_WriteBuffer method doesn't implement delayed EOL wrap. As a very simple test case, run printf "\e[999C*" with a breakpoint in the _WriteBuffer method. You'll see it write out the * character and then increment the X coordinate beyond the width of the page, passing that invalid value to _AdjustCursorPosition. That should never happen.
What it should be doing is recording the delayed wrap, and leaving the cursor where it is in the final column. You can see how it's handled in conhost here:
Lines 573 to 588 in 2b202ce
| // enforce a delayed newline if we're about to pass the end and the WC_DELAY_EOL_WRAP flag is set. | |
| if (WI_IsFlagSet(dwFlags, WC_DELAY_EOL_WRAP) && CursorPosition.X >= coordScreenBufferSize.X && fWrapAtEOL) | |
| { | |
| // Our cursor position as of this time is going to remain on the last position in this column. | |
| CursorPosition.X = coordScreenBufferSize.X - 1; | |
| // Update in the structures that we're still pointing to the last character in the row | |
| cursor.SetPosition(CursorPosition); | |
| // Record for the delay comparison that we're delaying on the last character in the row | |
| cursor.DelayEOLWrap(CursorPosition); | |
| } | |
| else | |
| { | |
| Status = AdjustCursorPosition(screenInfo, CursorPosition, WI_IsFlagSet(dwFlags, WC_KEEP_CURSOR_VISIBLE), psScrollY); | |
| } |
If more output is received after that, then the cursor will need to be moved to the start of the next line, before processing the output. Again you can see how that's handled in conhost here:
Lines 365 to 376 in 2b202ce
| // correct for delayed EOL | |
| if (cursor.IsDelayedEOLWrap() && fWrapAtEOL) | |
| { | |
| const COORD coordDelayedAt = cursor.GetDelayedAtPosition(); | |
| cursor.ResetDelayEOLWrap(); | |
| // Only act on a delayed EOL if we didn't move the cursor to a different position from where the EOL was marked. | |
| if (coordDelayedAt.X == CursorPosition.X && coordDelayedAt.Y == CursorPosition.Y) | |
| { | |
| CursorPosition.X = 0; | |
| CursorPosition.Y++; | |
| Status = AdjustCursorPosition(screenInfo, CursorPosition, WI_IsFlagSet(dwFlags, WC_KEEP_CURSOR_VISIBLE), psScrollY); |
The bottom line is that WT doesn't have a fully functional WriteBuffer implementation - I think that's what #780 was meant to resolve.
Originally posted by James Holderness (@j4james) in #8730 (comment)
Activity
carlos-zamora commentedon Feb 8, 2022
Mike Griese (@zadjii-msft) wasn't sure which milestone to put this one in. This affects rendering too, so I feel like it should be more important than
Backlog, but I don't think we'll be able to get to it in 1.12. 🤷zadjii-msft commentedon Feb 8, 2022
I'm gonna toss this into 22H2, because I'm gonna guess this is part of the wild ride that is #5800. I'll put it there and make sure it won't just go away with #8000 later.
Validate cursor position in UIA UTR ctor (#12436)
Validate cursor position in UIA UTR ctor (#12436)
Validate cursor position in UIA UTR ctor (#12436)
Validate cursor position in UIA UTR ctor (#12436)