-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maintain scrollbar position during a resize operation #4903
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
We won't be able to clear the one failed build, so I'm going to admin merge this when it's time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly some spelling nits but I'll approve it so you can just fix them up and merge it.
static HRESULT Reflow(TextBuffer& oldBuffer, | ||
TextBuffer& newBuffer, | ||
const std::optional<Microsoft::Console::Types::Viewport> lastCharacterViewport, | ||
std::optional<short>& oldViewportTop); | ||
std::optional<std::reference_wrapper<PositionInformation>> positionInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::optional<std::reference_wrapper<PositionInformation>> positionInfo); | |
std::optional<std::reference_wrapper<PositionInformation>> positionInfo = std::nullopt); |
I think you can do it for the lastCharacterViewport
parameter too.
Then the call you have in screenInfo doesn't have two std::nullopt
s passed through.
Up to you tho
Co-Authored-By: Carlos Zamora <carlos.zamora@microsoft.com>
Co-Authored-By: Carlos Zamora <carlos.zamora@microsoft.com>
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
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 ashort*
. So I was already going to change that to astd::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 themutableViewport
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