[PR #12561] Enable using the alt buffer in the Terminal #29118

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

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

State: closed
Merged: Yes


This PR allows the Terminal to actually use the alt buffer
appropriately. Currently, we just render the alt buffer state into the
main buffer and that is wild. It means things like vim will let the
user scroll up to see the previous history (which it shouldn't).

Very first thing this PR does: updates the
{Trigger|Invalidate}Circling methods to instead be
{Trigger|Invalidate}Flush(bool circling). We need this so that when an
app requests the alt buffer in conpty, we can immediately flush the
frame before asking the Terminal side to switch to the other buffer. The
Circling methods was a great place to do this, but we don't actually
want to set the circled flag in VtRenderer when that happens just for a
flush.

The Terminal's implementation is a little different than conhost's.
Conhost's implementation grew organically, so I had it straight up
create an entire new screen buffer for the alt buffer. The Terminal
doesn't need all that! All we need to do is have a separate TextBuffer
for the alt buffer contents. This makes other parts easier as well - we
don't really need to do anything with the _mutableViewport in the alt
buffer, because it's always in the same place. So, we can just leave it
alone and when we come back to the main buffer, there it is. Helper
methods have been updated to account for this.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/12561 **State:** closed **Merged:** Yes --- This PR allows the Terminal to actually use the alt buffer appropriately. Currently, we just render the alt buffer state into the main buffer and that is wild. It means things like `vim` will let the user scroll up to see the previous history (which it shouldn't). Very first thing this PR does: updates the `{Trigger|Invalidate}Circling` methods to instead be `{Trigger|Invalidate}Flush(bool circling)`. We need this so that when an app requests the alt buffer in conpty, we can immediately flush the frame before asking the Terminal side to switch to the other buffer. The `Circling` methods was a great place to do this, but we don't actually want to set the circled flag in VtRenderer when that happens just for a flush. The Terminal's implementation is a little different than conhost's. Conhost's implementation grew organically, so I had it straight up create an entire new screen buffer for the alt buffer. The Terminal doesn't need all that! All we need to do is have a separate `TextBuffer` for the alt buffer contents. This makes other parts easier as well - we don't really need to do anything with the `_mutableViewport` in the alt buffer, because it's always in the same place. So, we can just leave it alone and when we come back to the main buffer, there it is. Helper methods have been updated to account for this. * [x] Closes #381 * [x] Closes #3492 * [x] I work here * [x] Tests would be nice * #3686, #3082, #3321, #3493 are all good follow-ups here.
claunia added the pull-request label 2026-01-31 09:32:55 +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#29118