Skip to content
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

Merged
5 commits merged into from
Mar 16, 2020

Conversation

zadjii-msft
Copy link
Member

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

@zadjii-msft zadjii-msft added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Mar 13, 2020
@DHowett-MSFT
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DHowett-MSFT
Copy link
Contributor

We won't be able to clear the one failed build, so I'm going to admin merge this when it's time.

@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Mar 13, 2020
@ghost ghost requested review from miniksa, carlos-zamora and leonMSFT March 13, 2020 21:58
Copy link
Member

@carlos-zamora carlos-zamora left a 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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::nullopts passed through.

Up to you tho

src/cascadia/TerminalCore/Terminal.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalCore/Terminal.cpp Outdated Show resolved Hide resolved
DHowett and others added 2 commits March 13, 2020 15:18
Co-Authored-By: Carlos Zamora <carlos.zamora@microsoft.com>
Co-Authored-By: Carlos Zamora <carlos.zamora@microsoft.com>
@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Mar 16, 2020
@ghost
Copy link

ghost commented Mar 16, 2020

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit f1d3136 into master Mar 16, 2020
@ghost ghost deleted the dev/migrie/b/3494-maintain-scrollbar-position branch March 16, 2020 12:55
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) AutoMerge Marked for automatic merge by the bot when requirements are met Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintain scrollbar position during resize
4 participants