[PR #4903] Maintain scrollbar position during a resize operation #26026

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

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

State: closed
Merged: Yes


Summary of the Pull Request

Currently, when the user resizes the Terminal, we'll snap the visible viewport back to the bottom of the buffer. This PR changes the visible viewport of the Terminal to instead remain in the same relative location it was before the resize.

References

Made possible by our sponsors at #4741, and listeners like you.

PR Checklist

Detailed Description of the Pull Request / Additional comments

We already hated the std::optional<short>& thing I yeet'd into #4741 right at the end to replace a short*. So I was already going to change that to a std::optional<std::reference_wrapper<short>>, which is more idomatic. But then I was looking through the list of bugs and #3494 caught my eye. I realized it would be trivial to not only track the top of the mutableViewport during a resize, but we could use the same code path to track the visible viewport's start as well.

So basically I'm re-using that bit of code in Reflow to calculate the visible viewport's position too.

Validation Steps Performed

Gotta love just resizing things all day, errday

**Original Pull Request:** https://github.com/microsoft/terminal/pull/4903 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Currently, when the user resizes the Terminal, we'll snap the visible viewport back to the bottom of the buffer. This PR changes the visible viewport of the Terminal to instead remain in the same relative location it was before the resize. ## References Made possible by our sponsors at #4741, and listeners like you. ## PR Checklist * [x] Closes #3494 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments We already hated the `std::optional<short>&` thing I yeet'd into #4741 right at the end to replace a `short*`. So I was already going to change that to a `std::optional<std::reference_wrapper<short>>`, which is more idomatic. But then I was looking through the list of bugs and #3494 caught my eye. I realized it would be trivial to not only track the top of the `mutableViewport` during a resize, but we could use the same code path to track the _visible_ viewport's start as well. So basically I'm re-using that bit of code in `Reflow` to calculate the visible viewport's position too. ## Validation Steps Performed Gotta love just resizing things all day, errday
claunia added the pull-request label 2026-01-31 09:13:27 +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#26026