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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4415
Author: @zadjii-msft
Created: 1/30/2020
Status: Merged
Merged: 2/27/2020
Merged by: @undefined

Base: masterHead: dev/migrie/f/conpty-wrapping-003


📝 Commits (10+)

  • b5c8c85 let's first move reflowing to the text buffer
  • 9aec694 add a doc comment because I'm not a barbarian
  • 1a2654d Try to wrap the line properly with conpty
  • aae6ce6 This works, fixing the ECH at end of wrapped line bug
  • 416be46 This is some cleanup, almost ready for PR but I need to write tests which are blocked on #4213
  • 7f341a2 Merge branch 'master' into dev/migrie/f/conpty-wrapping-003
  • edeb346 I think this is all I need to support wrapped lines in the Terminal
  • ce3138c Let's pull all the test fixes into their own file
  • 4a7f2e4 Merge branch 'dev/migrie/b/just-conpty-test-fixes' into dev/migrie/f/conpty-wrapping-003
  • bfde821 A simple test for wrapped lines

📊 Changes

24 files changed (+512 additions, -35 deletions)

View changed files

📝 src/cascadia/TerminalCore/Terminal.cpp (+16 -0)
📝 src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp (+263 -2)
📝 src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp (+76 -0)
📝 src/cascadia/UnitTests_TerminalCore/TestUtils.h (+4 -0)
📝 src/host/ut_host/VtRendererTests.cpp (+5 -5)
📝 src/interactivity/onecore/BgfxEngine.cpp (+2 -1)
📝 src/interactivity/onecore/BgfxEngine.hpp (+2 -1)
📝 src/renderer/base/renderer.cpp (+12 -4)
📝 src/renderer/base/renderer.hpp (+2 -1)
📝 src/renderer/dx/DxRenderer.cpp (+2 -1)
📝 src/renderer/dx/DxRenderer.hpp (+2 -1)
📝 src/renderer/gdi/gdirenderer.hpp (+2 -1)
📝 src/renderer/gdi/paint.cpp (+2 -1)
📝 src/renderer/inc/IRenderEngine.hpp (+2 -1)
📝 src/renderer/uia/UiaRenderer.cpp (+2 -1)
📝 src/renderer/uia/UiaRenderer.hpp (+2 -1)
📝 src/renderer/vt/XtermEngine.cpp (+20 -4)
📝 src/renderer/vt/XtermEngine.hpp (+2 -2)
📝 src/renderer/vt/paint.cpp (+36 -4)
📝 src/renderer/vt/tracing.cpp (+45 -0)

...and 4 more files

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4415 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 1/30/2020 **Status:** ✅ Merged **Merged:** 2/27/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/f/conpty-wrapping-003` --- ### 📝 Commits (10+) - [`b5c8c85`](https://github.com/microsoft/terminal/commit/b5c8c854cc2d0000a09672112dc20e6a98639713) let's first move reflowing to the text buffer - [`9aec694`](https://github.com/microsoft/terminal/commit/9aec69467cf72c536fca001abc4e82222012307e) add a doc comment because I'm not a barbarian - [`1a2654d`](https://github.com/microsoft/terminal/commit/1a2654d291e530a189c376702d6f47ecc05c84bc) Try to wrap the line properly with conpty - [`aae6ce6`](https://github.com/microsoft/terminal/commit/aae6ce60a491036f5917042efe6a85fee76ea67a) This works, fixing the ECH at end of wrapped line bug - [`416be46`](https://github.com/microsoft/terminal/commit/416be4656febb708193ed7ecc36914c6e98c1333) This is some cleanup, almost ready for PR but I need to write tests which are blocked on #4213 - [`7f341a2`](https://github.com/microsoft/terminal/commit/7f341a25a58a360a38af75c1619bba44566f73ce) Merge branch 'master' into dev/migrie/f/conpty-wrapping-003 - [`edeb346`](https://github.com/microsoft/terminal/commit/edeb3463253d29d8edc72ad591d11e790eea7ab8) I think this is all I need to support wrapped lines in the Terminal - [`ce3138c`](https://github.com/microsoft/terminal/commit/ce3138c6853840e6e1bf4f13c374501cbf26a352) Let's pull all the test fixes into their own file - [`4a7f2e4`](https://github.com/microsoft/terminal/commit/4a7f2e4f7b6069ad8f4f400a87187117aa5a7fc9) Merge branch 'dev/migrie/b/just-conpty-test-fixes' into dev/migrie/f/conpty-wrapping-003 - [`bfde821`](https://github.com/microsoft/terminal/commit/bfde821b2fab316765edec3764c07b992e7cad5c) A simple test for wrapped lines ### 📊 Changes **24 files changed** (+512 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+16 -0) 📝 `src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp` (+263 -2) 📝 `src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp` (+76 -0) 📝 `src/cascadia/UnitTests_TerminalCore/TestUtils.h` (+4 -0) 📝 `src/host/ut_host/VtRendererTests.cpp` (+5 -5) 📝 `src/interactivity/onecore/BgfxEngine.cpp` (+2 -1) 📝 `src/interactivity/onecore/BgfxEngine.hpp` (+2 -1) 📝 `src/renderer/base/renderer.cpp` (+12 -4) 📝 `src/renderer/base/renderer.hpp` (+2 -1) 📝 `src/renderer/dx/DxRenderer.cpp` (+2 -1) 📝 `src/renderer/dx/DxRenderer.hpp` (+2 -1) 📝 `src/renderer/gdi/gdirenderer.hpp` (+2 -1) 📝 `src/renderer/gdi/paint.cpp` (+2 -1) 📝 `src/renderer/inc/IRenderEngine.hpp` (+2 -1) 📝 `src/renderer/uia/UiaRenderer.cpp` (+2 -1) 📝 `src/renderer/uia/UiaRenderer.hpp` (+2 -1) 📝 `src/renderer/vt/XtermEngine.cpp` (+20 -4) 📝 `src/renderer/vt/XtermEngine.hpp` (+2 -2) 📝 `src/renderer/vt/paint.cpp` (+36 -4) 📝 `src/renderer/vt/tracing.cpp` (+45 -0) _...and 4 more files_ </details> ### 📄 Description ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:11:36 +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#25756