-
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
Reset _wrapForced when erasing scrollback #16610
Conversation
(FWIW, the class name is "Adapt"Dispatch :)) |
// The start parameter is relative to the _firstRow. The trick to get the content to the absolute start | ||
// is to simply add _firstRow ourselves and then reset it to 0. This causes ScrollRows() to write into | ||
// the absolute start while reading from relative coordinates. This works because GetRowByOffset() | ||
// operates modulo the buffer height and so the possibly-too-large startAbsolute won't be an issue. |
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 is horrifying
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.
Yeah... Alternative approaches aren't particularly nice either unfortunately, hence the big comment. But I believe this will remain the only function that would need such a trick, so the impact is at least limited. 😅
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.
okay I think I follow. Kinda surprised that a test didn't catch this?
#15541 changed `AdaptDispatch::_FillRect` which caused it to not affect the `ROW::_wrapForced` flag anymore. This change in behavior was not noticeable as `TextBuffer::GetLastNonSpaceCharacter` had a bug where rows of only whitespace text would always be treated as empty. This would then affect `AdaptDispatch::_EraseAll` to accidentally correctly guess the last row with text despite the `_FillRect` change. #15701 then fixed `GetLastNonSpaceCharacter` indirectly by fixing `ROW::MeasureRight` which now made the previous change apparent. `_EraseAll` would now guess the last row of text incorrectly, because it would find the rows that `_FillRect` cleared but still had `_wrapForced` set to `true`. This PR fixes the issue by replacing the `_FillRect` usage to clear rows with direct calls to `ROW::Reset()`. In the future this could be extended by also `MEM_DECOMMIT`ing the now unused underlying memory. Closes #16603 ## Validation Steps Performed * Enter WSL and resize the window to <40 columns * Execute ```sh cd /bin ls -la printf "\e[3J" ls -la printf "\e[3J" printf "\e[2J" ``` * Only one viewport-height-many lines of whitespace exist between the current prompt line and the previous scrollback contents ✅ (cherry picked from commit 5f71cf3) Service-Card-Id: 91707937 Service-Version: 1.19
#15541 changed
AdaptDispatch::_FillRect
which caused it to not affectthe
ROW::_wrapForced
flag anymore. This change in behavior was notnoticeable as
TextBuffer::GetLastNonSpaceCharacter
had a bug whererows of only whitespace text would always be treated as empty.
This would then affect
AdaptDispatch::_EraseAll
to accidentallycorrectly guess the last row with text despite the
_FillRect
change.#15701 then fixed
GetLastNonSpaceCharacter
indirectly by fixingROW::MeasureRight
which now made the previous change apparent._EraseAll
would now guess the last row of text incorrectly,because it would find the rows that
_FillRect
cleared but stillhad
_wrapForced
set totrue
.This PR fixes the issue by replacing the
_FillRect
usage to clearrows with direct calls to
ROW::Reset()
. In the future this could beextended by also
MEM_DECOMMIT
ing the now unused underlying memory.Closes #16603
Validation Steps Performed
current prompt line and the previous scrollback contents ✅