-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Improve Viewport and Viewport::WalkInBounds #17143
Conversation
0cbd028
to
75e4f06
Compare
I'd be reluctant to merge this for 1.21 based solely on the fact that these are used everywhere and I'm guessing that bugs in the delta will be very subtle. But I'd be very happy to merge early in 1.22 when we've got more runway to validate. (I'm also open to being overruled) |
bufferViewport.WalkInBounds(afterPos, | ||
walkDir); | ||
} | ||
bufferViewport.WalkInBounds(afterPos, -dx); |
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.
@zadjii-msft Here's why the tests failed... I previously had this as:
bufferViewport.WalkInBounds(afterPos, dx);
but on closer inspection of the old code I noticed that the dx
is meant inverse to an offset. I don't quite understand the old code to say why that is, but it does work now by simply using -dx
.
I guess I'm being overly defensive over my PR here, but I do think it's fairly solid after all. 😅 (To be clear I don't mind merging it in 1.22 only.)
FWIW, I've run a number of my own rectangle and scrolling tests on this branch, and I couldn't see any regressions. |
@lhecker Make sure you test this with Narrator. The bounding rects aren't updating for me. |
@carlos-zamora I believe this is a race condition in the UIA implementation. I found that it also reproduces in the stable builds (here: v1.20; repeatedly open cmd and hold any key immediately): The new-ish |
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.
why was I scared of reviewing this?
} | ||
|
||
return true; | ||
const auto l = static_cast<ptrdiff_t>(_sr.left); |
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.
this makes me think "why were we doing it any other way before"
I was scared too, can't figure out why |
This removes all of the 2D iteration machinery. Imagine the text buffer
as a
Cell[w][h]
grid. Clearly, this is identical to aCell[w*h]
array, which shows that copying between overlapping ranges only needs
either forward or backward copying, and not left/right/top/down.
With
WalkDir
removed,WalkInBounds
can be rewritten with basicarithmetic which allows
pos
to be an exclusive end coordinate.