[PR #14661] [MERGED] Correct the cursor invalidation region #30188

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/14661
Author: @j4james
Created: 1/10/2023
Status: ✅ Merged
Merged: 1/11/2023
Merged by: @undefined

Base: main ← Head: fix-wide-cursor-droppings


📝 Commits (1)

  • d770fef Correct the cursor invalidation region.

📊 Changes

1 file changed (+7 additions, -6 deletions)

View changed files

📝 src/renderer/base/renderer.cpp (+7 -6)

📄 Description

Depending on the line rendition, and whether the cursor is over a wide
character or not, it's possible for the width to take up anywhere from 1
to 4 cells. And when it's more than 1 cell wide, part of the cursor may
end up off screen. However, our bounds check requires the entire cursor
to be on screen, otherwise it doesn't render anything, and that can
result in cursor droppings being left behind. This PR fixes that.

The bounds check that is causing this issue was introduced in #13001 to
fix a debug assertion.

To fix this, I've removed the bounds checking, and instead clip the
cursor rect to the boundaries of the viewport. This is what the original
code was trying to do prior to the #13001 fix, but was mistakenly using
the Viewport:Clamp method, instead of TrimToViewport. Since this
implementation doesn't require a clamp, there should be no risk of the
debug assertion returning.

Validation Steps Performed

I've confirmed that the test case in #14657 is now working correctly,
and not leaving cursor droppings behind. I've also tested under conhost
with buffer sizes wider than the viewport, and confirmed it can handle a
wide cursor partially scrolled off screen.

Closes #14657


🔄 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/14661 **Author:** [@j4james](https://github.com/j4james) **Created:** 1/10/2023 **Status:** ✅ Merged **Merged:** 1/11/2023 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `fix-wide-cursor-droppings` --- ### 📝 Commits (1) - [`d770fef`](https://github.com/microsoft/terminal/commit/d770fef1d348fb6effd947847585a53648f9f09b) Correct the cursor invalidation region. ### 📊 Changes **1 file changed** (+7 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/renderer/base/renderer.cpp` (+7 -6) </details> ### 📄 Description Depending on the line rendition, and whether the cursor is over a wide character or not, it's possible for the width to take up anywhere from 1 to 4 cells. And when it's more than 1 cell wide, part of the cursor may end up off screen. However, our bounds check requires the entire cursor to be on screen, otherwise it doesn't render anything, and that can result in cursor droppings being left behind. This PR fixes that. The bounds check that is causing this issue was introduced in #13001 to fix a debug assertion. To fix this, I've removed the bounds checking, and instead clip the cursor rect to the boundaries of the viewport. This is what the original code was trying to do prior to the #13001 fix, but was mistakenly using the `Viewport:Clamp` method, instead of `TrimToViewport`. Since this implementation doesn't require a clamp, there should be no risk of the debug assertion returning. ## Validation Steps Performed I've confirmed that the test case in #14657 is now working correctly, and not leaving cursor droppings behind. I've also tested under conhost with buffer sizes wider than the viewport, and confirmed it can handle a wide cursor partially scrolled off screen. Closes #14657 --- <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:39:13 +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#30188