[PR #16610] Reset _wrapForced when erasing scrollback #30956

Open
opened 2026-01-31 09:44:04 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/16610

State: closed
Merged: Yes


#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_DECOMMITing the now unused underlying memory.

Closes #16603

Validation Steps Performed

  • Enter WSL and resize the window to <40 columns
  • Execute
    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 ✅
**Original Pull Request:** https://github.com/microsoft/terminal/pull/16610 **State:** closed **Merged:** Yes --- #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 ✅
claunia added the pull-request label 2026-01-31 09:44:04 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30956