Skip to content

\n with ENABLE_PROCESSED_OUTPUT and without ENABLE_WRAP_AT_EOL_OUTPUT #18735

Closed
@malxau-msft

Description

@malxau-msft

Windows Terminal version

1.22.2362

Windows build number

10.0.19045

Other Software

No response

Steps to reproduce

Disable ENABLE_WRAP_AT_EOL_OUTPUT, keep ENABLE_PROCESSED_OUTPUT enabled, write to the end of line, then insert \n . Traditionally the newline would operate as CRLF (processed output semantics) and start at the beginning of the following line. Note this is Win32 semantics, VT semantics are different; in this sequence, VT support is not enabled.

In WT 1.22.x, this generates VT semantics. Replacing \n with \r\n works as expected.

#include <windows.h>

int main(int argc, char * argv[])
{
    CONSOLE_SCREEN_BUFFER_INFO screenBufferInfo;
    DWORD consoleWidth;
    DWORD charIndex;
    DWORD lineIndex;
    DWORD charsWritten;
    HANDLE consoleHandle;
    LPSTR buffer;

    consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(consoleHandle, &screenBufferInfo);
    consoleWidth = screenBufferInfo.dwSize.X;

    //
    //  Disable ENABLE_WRAP_AT_EOL_OUTPUT
    //
    SetConsoleMode(consoleHandle, ENABLE_PROCESSED_OUTPUT);
    buffer = malloc(consoleWidth + 1);

    for (lineIndex = 0; lineIndex < 3; lineIndex++) {
        for (charIndex = 0; charIndex < consoleWidth; charIndex++) {
            buffer[charIndex] = '1' + lineIndex;
        }
        WriteConsole(consoleHandle, buffer, consoleWidth, &charsWritten, NULL);
        WriteConsole(consoleHandle, "\n", 1, &charsWritten, NULL);
    }

    return 0;
}

Expected Behavior

Behavior in WT 1.21, as well as Conhost, including OpenConsole from WT 1.22:

Image

Actual Behavior

Behavior in WT 1.22:

Image

Metadata

Metadata

Assignees

Labels

Area-ServerDown in the muck of API call servicing, interprocess communication, eventing, etc.Issue-BugIt either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsPriority-1A description (P1)Product-ConptyFor console issues specifically related to conpty

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions