Skip to content

Properly implement delayed EOL wrap in Terminal::_WriteBuffer #12440

Closed

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:

// 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:

// 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

  1. added
    Area-Output
    Product-Terminal
    Issue-Task
    on Feb 8, 2022
  2. ghost added
    Needs-Triage
    on Feb 8, 2022
  3. carlos-zamora commented on Feb 8, 2022

    @carlos-zamora
    Author

    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. 🤷

  4. zadjii-msft commented on Feb 8, 2022

    @zadjii-msft
    Member

    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.

  5. removed
    Needs-Triage
    on Feb 8, 2022
  6. added this to the 22H2 milestone on Feb 8, 2022
  7. ghost added
    In-PR
    on Jan 6, 2023
  8. ghost closed this as completedin a1865b9on Jan 18, 2023
  9. ghost closed this as completedin #14640on Jan 18, 2023
  10. ghost removed
    In-PR
    on Jan 18, 2023
  11. ghost added
    Resolution-Fix-Committed
    on Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-OutputIssue-TaskProduct-TerminalResolution-Fix-Committed

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions