\n with ENABLE_PROCESSED_OUTPUT and without ENABLE_WRAP_AT_EOL_OUTPUT #23080

Closed
opened 2026-01-31 08:31:43 +00:00 by claunia · 1 comment
Owner

Originally created by @malxau-msft on GitHub (Mar 28, 2025).

Originally assigned to: @lhecker on GitHub.

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

Originally created by @malxau-msft on GitHub (Mar 28, 2025). Originally assigned to: @lhecker on GitHub. ### 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](https://github.com/user-attachments/assets/77fcdf2e-5693-4294-965c-08c7f5e3a1f8) ### Actual Behavior Behavior in WT 1.22: ![Image](https://github.com/user-attachments/assets/296a4a57-0c42-4c7b-bd65-6c165e28eb35)
claunia added the Issue-BugNeeds-Tag-FixArea-ServerProduct-ConptyPriority-1 labels 2026-01-31 08:31:44 +00:00
Author
Owner

@DHowett commented on GitHub (Apr 2, 2025):

Whoa, thanks for catching this! Probably an issue in the new (as of 1.22) translation layer for console APIs to VT. :)

@DHowett commented on GitHub (Apr 2, 2025): Whoa, thanks for catching this! Probably an issue in the new (as of 1.22) translation layer for console APIs to VT. :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23080