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

[1.14] Fix moving selection past scroll area #13353

Merged
merged 5 commits into from
Jun 22, 2022

Conversation

carlos-zamora
Copy link
Member

Summary of the Pull Request

1.14 port of #13318

Introduced in #10824, this fixes a bug where you could use keyboard selection to move below the scroll area. Instead, we now clamp movement to the mutable viewport (aka the scrollable area). Specifically, we only clamp the y-coordinate to make the experience similar to that of mouse selection.

Validation Steps Performed

✅ (no output) try to move past bottom of viewport
✅ (with output, at bottom of scroll area) try to move past viewport
✅ (with output, NOT at bottom of scroll area) try to move past viewport
✅ try to move past top of viewport

@carlos-zamora carlos-zamora requested a review from DHowett June 21, 2022 18:59
src/cascadia/TerminalCore/TerminalSelection.cpp Outdated Show resolved Hide resolved
Comment on lines +323 to +333
if (const auto visibleViewport = _GetVisibleViewport(); !visibleViewport.IsInBounds(targetPos))
{
if (const auto amtAboveView = viewport.Top() - targetPos.Y; amtAboveView > 0)
if (const auto amtAboveView = visibleViewport.Top() - targetPos.Y; amtAboveView > 0)
{
// anchor is above visible viewport, scroll by that amount
_scrollOffset += amtAboveView;
}
else
{
// anchor is below visible viewport, scroll by that amount
const auto amtBelowView = targetPos.Y - viewport.BottomInclusive();
const auto amtBelowView = targetPos.Y - visibleViewport.BottomInclusive();
Copy link
Member

Choose a reason for hiding this comment

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

These changes appear unnecessary right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh, they're more helpful on main than here. I just wanted to create more clarity to distinguish between the visible viewport and mutable viewport. I'll still keep it at least to keep things as consistent as possible between these two branches.

lhecker
lhecker previously approved these changes Jun 21, 2022
@carlos-zamora
Copy link
Member Author

Interesting! If you merge a code suggestion, approved reviews are dismissed. @lhecker you're gonna have to look over this again. Sorry!

@zadjii-msft
Copy link
Member

If you merge a code suggestion, approved reviews are dismissed

That's a branch policy that applies to all release-* branches. We'll probably have to bring that back for main sometime soon, FYI

@DHowett DHowett merged commit 7506a3a into release-1.14 Jun 22, 2022
@DHowett DHowett deleted the dev/cazamor/1.14/bugfix-movePastBottom branch June 22, 2022 16:16
DHowett pushed a commit that referenced this pull request Jun 30, 2022
A port of commit 0c5a1e9 from #13358.
This fixes an oversight from #13353. That ended up not fixing when trying to move past the top boundary.
This is also a better fix overall. By moving the fix to `_MoveByChar`, we have consistency between all the `_MoveByX` functions in that they automatically clamp to be within the scroll area.
@ghost
Copy link

ghost commented Jul 6, 2022

🎉Windows Terminal v1.14.186 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants