[PR #13087] [MERGED] Restore virtual viewport position after resize with reflow #29377

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13087
Author: @j4james
Created: 5/12/2022
Status: Merged
Merged: 5/12/2022
Merged by: @undefined

Base: mainHead: fix-virtual-viewport-2


📝 Commits (3)

  • 4bfebcc Improve the virtual bottom calculation in ResizeWithReflow.
  • 804e899 Extend the ResizeWithReflow unit tests.
  • 1604737 Make sure virtual bottom isn't out of range.

📊 Changes

2 files changed (+25 additions, -5 deletions)

View changed files

📝 src/host/screenInfo.cpp (+13 -5)
📝 src/host/ut_host/ScreenBufferTests.cpp (+12 -0)

📄 Description

When the buffer is resized with a reflow, we were previously calculating
the new virtual bottom based on the position of last non-space
character. If the viewport was largely blank when resized, this could
result in the new virtual bottom being higher than it should be.

This PR attempts to address that problem by restoring the virtual bottom
to a position that is the same distance from the cursor row as it was
prior to the resize.

This was a regression introduced in PR #12972.

We still take the last non-space row into account when determining the
virtual bottom, because if the content of the screen is forced to wrap,
the virtual bottom will need to be lower (relative to the cursor) than
it was before.

We also need to check that we don't overflow the bottom of the buffer,
which can occur when the viewport is at the bottom of the buffer, and
the cursor position is pushed down as a result of content wrapping above
it.

I've manually confirmed that this fixes the problem reported in issue
#13078, and I've also extended the existing RefreshWithReflow unit
test to cover that particular scenario.

Closes #13078


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/13087 **Author:** [@j4james](https://github.com/j4james) **Created:** 5/12/2022 **Status:** ✅ Merged **Merged:** 5/12/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `fix-virtual-viewport-2` --- ### 📝 Commits (3) - [`4bfebcc`](https://github.com/microsoft/terminal/commit/4bfebcc70ab9a8fd6b3b0d7a89385a85d7d99077) Improve the virtual bottom calculation in ResizeWithReflow. - [`804e899`](https://github.com/microsoft/terminal/commit/804e8995be857ab8c7c0a35e4930fc25a5c0e07f) Extend the ResizeWithReflow unit tests. - [`1604737`](https://github.com/microsoft/terminal/commit/160473702cd2070da82bf1bee40c9cab54666dd6) Make sure virtual bottom isn't out of range. ### 📊 Changes **2 files changed** (+25 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/host/screenInfo.cpp` (+13 -5) 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+12 -0) </details> ### 📄 Description When the buffer is resized with a reflow, we were previously calculating the new virtual bottom based on the position of last non-space character. If the viewport was largely blank when resized, this could result in the new virtual bottom being higher than it should be. This PR attempts to address that problem by restoring the virtual bottom to a position that is the same distance from the cursor row as it was prior to the resize. This was a regression introduced in PR #12972. We still take the last non-space row into account when determining the virtual bottom, because if the content of the screen is forced to wrap, the virtual bottom will need to be lower (relative to the cursor) than it was before. We also need to check that we don't overflow the bottom of the buffer, which can occur when the viewport is at the bottom of the buffer, and the cursor position is pushed down as a result of content wrapping above it. I've manually confirmed that this fixes the problem reported in issue #13078, and I've also extended the existing `RefreshWithReflow` unit test to cover that particular scenario. Closes #13078 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:34:32 +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#29377