OSC escape sequences received out-of-order in 3rd-party terminals #21762

Open
opened 2026-01-31 07:54:12 +00:00 by claunia · 0 comments
Owner

Originally created by @acarl005 on GitHub (May 23, 2024).

Windows Terminal version

1.19.11213.0

Windows build number

10.0.22631.0

Other Software

No response

Steps to reproduce

ANSI compatibility has been pretty good in ConPTY. We're coming up on some niche cases.

In a 3rd-party terminal, e.g. alacritty, produce some text with an OSC escape sequence interleaved between some text.

PowerShell 7.4.2
PS> echo "hello `e]2;new title`a world"
hello  world

Visually, things look pretty OK. The correct text is echo'd and the title is changed.

Screenshot 2024-05-23 195707

But, here is the exact data that alacritty read out of ConPTY:


hello  world
PS> ESC]0;new titleBEL

Observe that when the text was produced in the shell, the OSC command to set title was between "hello" and "world". However, when the text was read out of ConPTY by the terminal, the ordering is changed.

Expected Behavior

I expect the ordering of text, including the ANSI escape sequences, to be preserved.

Actual Behavior

ANSI escape sequences are being parsed and re-serialized in a "lossy" way. While this may be necessary when a Windows Terminal is involved, it isn't when the terminal application only receives ANSI sequences. That is, there is no need to try to parse the ANSI. ConPTY does still need to convert console API calls coming from Windows command-line apps, but plain ANSI text doesn't need any conversion.

Originally created by @acarl005 on GitHub (May 23, 2024). ### Windows Terminal version 1.19.11213.0 ### Windows build number 10.0.22631.0 ### Other Software _No response_ ### Steps to reproduce ANSI compatibility has been pretty good in ConPTY. We're coming up on some niche cases. In a 3rd-party terminal, e.g. alacritty, produce some text with an OSC escape sequence _interleaved_ between some text. ``` PowerShell 7.4.2 PS> echo "hello `e]2;new title`a world" hello world ``` Visually, things look pretty OK. The correct text is echo'd and the title is changed. ![Screenshot 2024-05-23 195707](https://github.com/microsoft/terminal/assets/8334252/55ecf7a0-4559-474c-b9ed-a8625c4f0fd0) But, here is the exact data that alacritty read out of ConPTY: ``` hello world PS> ESC]0;new titleBEL ``` Observe that when the text was produced in the shell, the OSC command to set title was between "hello" and "world". However, when the text was read out of ConPTY by the terminal, the ordering is changed. ### Expected Behavior I expect the ordering of text, including the ANSI escape sequences, to be preserved. ### Actual Behavior ANSI escape sequences are being parsed and re-serialized in a "lossy" way. While this may be necessary when a Windows Terminal is involved, it isn't when the terminal application only receives ANSI sequences. That is, there is no need to try to parse the ANSI. ConPTY does still need to convert console API calls coming from Windows command-line apps, but plain ANSI text doesn't need any conversion.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 07:54:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21762