microsoft / microsoft/terminal

[megathread] ConPTY buffer gets out-of-sync

Open
#15,976 5 comments 2 reactions 1 assignee Claimed by @lhecker View on GitHub
Issue-Scenario Product-Conpty
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

_maintainer edit_: we're promoting this to a megathread cause this is a **H**ard problem. This is now tracking "try to make an in-proc version of conpty"

See: https://github.com/microsoft/terminal/issues/15976#issuecomment-1722596700 for details.

Thoughts:
* [ ] fix the conhost singletons?
* [ ] Load conhost.exe as a dll
* [ ] Keep the pipes (but in proc!)

Things we might be able to actually solve with this:
* #7449
* #20437

----

### Windows Terminal version

1.17.11461.0

### Windows build number

22621.2283

### Other Software

_No response_

### Steps to reproduce

This is an indirect repro, since we can't see how the openconsole buffer looks like at any instant when it's acting as a conpty.

- Open `wt.exe` and `openconsole.exe`.
- Go to open console's **Layout** settings, and set **"Screen Buffer Size"** height to 1 (for now, this removes the scrollback region and makes *this* openconsole behave like conpty.)
- Pick a string that can easily *wrap* several times if we shrink the window size for both WT and OpenConsole, example:
```txt
"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80"
```
- Put the string into the prompt and try to find an optimal window size where both the WT and openconsole has exactly the same amount of rows and cols on the screen. **Avoid having scrollbars on OpenConsole while doing this, scrollbars means *scrollback* height is not 0 anymore, which is important for this repro**. I used 12(r) x 35(c).
- Fill the buffer with the above text. If you're using `pwsh`, you can simply press `enter`, and it will echo the string back. That should be enough in this case.
- Now, increase the width of the window for both WT and openconsole one by one, by 1 level. This should cause a "reflow" as we call it.
- After the reflow, WT and openconsole is out of sync on the first line of the viewport.

### Expected Behavior

After the reflow, both buffers should stay in sync.

### Actual Behavior

Buffers are out of sync.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.