[PR #4415] Make Conpty emit wrapped lines as actually wrapped lines #25761

Closed
opened 2026-01-31 09:11:38 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/4415

State: closed
Merged: Yes


Summary of the Pull Request

Changes how conpty emits text to preserve line-wrap state, and additionally adds rudimentary support to the Windows Terminal for wrapped lines.

References

  • Does not fix (!) #3088, but that might be lower down in conhost. This makes wt behave like conhost, so at least there's that
  • Still needs a proper deferred EOL wrap implementation in #780, which is left as a todo
  • #4200 is the mega bucket with all this work
  • MSFT:16485846 was the first attempt at this task, which caused the regression MSFT:18123777 so we backed it out.
  • #4403 - I made sure this worked with that PR before I even sent #4403

PR Checklist

Detailed Description of the Pull Request / Additional comments

I started with the following implementation:
When conpty is about to write the last column, note that we wrapped this line here. If the next character the vt renderer is told to paint get is supposed to be at the start of the following line, then we know that the previous line had wrapped, so we won't emit the usual \r\n here, and we'll just continue emitting text.

However, this isn't exactly right - if someone fills the row exactly with text, the information that's available to the vt renderer isn't enough to know for sure if this line broke or not. It is possible for the client to write a full line of text, with a \n at the end, to manually break the line. So, I had to also add the lineWrapped param to the IRenderEngine interface, which is about half the files in this changelist.

Validation Steps Performed

  • Ran tests
  • Checked how the Windows Terminal behaves with these changes
  • Made sure that conhost/inception and gnome-terminal both act as you'd expect with wrapped lines from conpty
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4415 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Changes how conpty emits text to preserve line-wrap state, and additionally adds rudimentary support to the Windows Terminal for wrapped lines. ## References * Does _not_ fix (!) #3088, but that might be lower down in conhost. This makes wt behave like conhost, so at least there's that * Still needs a proper deferred EOL wrap implementation in #780, which is left as a todo * #4200 is the mega bucket with all this work * MSFT:16485846 was the first attempt at this task, which caused the regression MSFT:18123777 so we backed it out. * #4403 - I made sure this worked with that PR before I even sent #4403 ## PR Checklist * [x] Closes #405 * [x] Closes #3367 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments I started with the following implementation: When conpty is about to write the last column, note that we wrapped this line here. If the next character the vt renderer is told to paint get is supposed to be at the start of the following line, then we know that the previous line had wrapped, so we _won't_ emit the usual `\r\n` here, and we'll just continue emitting text. However, this isn't _exactly_ right - if someone fills the row _exactly_ with text, the information that's available to the vt renderer isn't enough to know for sure if this line broke or not. It is possible for the client to write a full line of text, with a `\n` at the end, to manually break the line. So, I had to also add the `lineWrapped` param to the `IRenderEngine` interface, which is about half the files in this changelist. ## Validation Steps Performed * Ran tests * Checked how the Windows Terminal behaves with these changes * Made sure that conhost/inception and gnome-terminal both act as you'd expect with wrapped lines from conpty
claunia added the pull-request label 2026-01-31 09:11:38 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25761