ConPTY repeats character at top left of buffer during every operation #343

Open
opened 2026-01-30 21:49:30 +00:00 by claunia · 0 comments
Owner

Originally created by @melak47 on GitHub (Aug 19, 2018).

Originally assigned to: @zadjii-msft on GitHub.

Windows (Insider) Build is 10.0.17713.1002

I'm trying out the new pseudo terminal support, and capturing the output of a program that simply prints hello, world! to stdout produces the following:

[?25lhello, world![?25hhh

Breaking this down:

0x1B[2J       # clear screen??
0x1B[?25l     # hide cursor
0x1B[39m      # default foreground color
0x1B[49m      # default background color
0x1B[H        # move cursor home??
hello, world! #
0x08          # Backspace key??
0x1B[?25h     # show cursor
0x1B[H        # move cursor home??
h             # print 'h' over the first char??
0x1B[H        #
h             # ...twice??
0x1B[1;14H    # move cursor after printed text
0x1B[1;14H    # ...twice??

Now some of these make sense, but a few I find confusing.
Why clear the screen? (Either the user provided an empty file or a pipe to the PTY, or they intended to collect more than once programs output - at worst the clearing is unnecessary, at worst unwanted)
Why move the cursor to the top left?
Where does the backspace control character come from?
Why is the first character (h) overwritten twice, are erroneously detected changes of the output buffer being rendered as VT sequences here?

Originally created by @melak47 on GitHub (Aug 19, 2018). Originally assigned to: @zadjii-msft on GitHub. Windows (Insider) Build is 10.0.17713.1002 I'm trying out the new pseudo terminal support, and capturing the output of a program that simply prints `hello, world!` to stdout produces the following: ``` [?25lhello, world![?25hhh ``` Breaking this down: ``` 0x1B[2J # clear screen?? 0x1B[?25l # hide cursor 0x1B[39m # default foreground color 0x1B[49m # default background color 0x1B[H # move cursor home?? hello, world! # 0x08 # Backspace key?? 0x1B[?25h # show cursor 0x1B[H # move cursor home?? h # print 'h' over the first char?? 0x1B[H # h # ...twice?? 0x1B[1;14H # move cursor after printed text 0x1B[1;14H # ...twice?? ``` Now some of these make sense, but a few I find confusing. Why clear the screen? (Either the user provided an empty file or a pipe to the PTY, or they intended to collect more than once programs output - at worst the clearing is unnecessary, at worst unwanted) Why move the cursor to the top left? Where does the backspace control character come from? Why is the first character (h) overwritten twice, are erroneously detected changes of the output buffer being rendered as VT sequences here?
claunia added the Resolution-Fix-AvailableWork-ItemProduct-Conpty labels 2026-01-30 21:49:30 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#343