Repository: microsoft/terminal (language: cpp)

Issue:
Ghostly cursor droppings in OpenConsole
### Windows Terminal version

Commit e826203bb7e200f6f7029b6d8be68fb330c18735

### Windows build number

10.0.19045.4412

### Other Software

_No response_

### Steps to reproduce

1. Build a recent commit of OpenConsole.
2. Start a cmd shell.
3. Set the cursor shape to _Solid Block_ so it's easy to see.
4. Hold down <kbd>Enter</kbd> and let the viewport scroll for a while.

### Expected Behavior

You should only see the cursor on the last prompt of the page.

### Actual Behavior

After a short while, you'll start to see a trail of ghostly cursor droppings left behind on most of the lines. They don't look like the full cursor droppings we've had in the past though - they seem to be about 25% of the usual brightness.

![image](https://github.com/microsoft/terminal/assets/4181424/4c351633-3744-409b-a1f8-58b479fdd651)



Discussion / hints:
Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!


### Closed similar issues:
- [Cursor droppings are back in conhost (#12739)](https://github.com/microsoft/terminal/issues/12739),  similarity score: 0.81
- [Bug Report: PowerShell in 1903 cursor ghosting (#1128)](https://github.com/microsoft/terminal/issues/1128),  similarity score: 0.78
- [More cursor droppings (#8213)](https://github.com/microsoft/terminal/issues/8213),  similarity score: 0.76
- [Cursor droppings on wide chars in Windows Terminal (#14657)](https://github.com/microsoft/terminal/issues/14657),  similarity score: 0.76

> Note: You can give me feedback by thumbs upping or thumbs downing this comment.
This looks like it regressed in 4fbcd65e1abc073e510b3a532c2a40a34d9af734. I don't have time to investigate now, but if I remember correctly the GDI engine used to have some special case handling for the cursor when scrolling, so that might have something to do with this. The problem doesn't occur if the Atlas engine is used.

Fix patch:
diff --git a/src/renderer/base/renderer.cpp b/src/renderer/base/renderer.cpp
index c8ed8b28e7b..261b7f88cbf 100644
--- a/src/renderer/base/renderer.cpp
+++ b/src/renderer/base/renderer.cpp
@@ -432,7 +432,11 @@ bool Renderer::_CheckViewportAndScroll()
     // The cursor may have moved out of or into the viewport. Update the .inViewport property.
     {
         const auto view = ScreenToBufferLine(srNewViewport, _currentCursorOptions.lineRendition);
-        const auto coordCursor = _currentCursorOptions.coordCursor;
+        auto coordCursor = _currentCursorOptions.coordCursor;
+
+        // `coordCursor` was stored in viewport-relative while `view` is in absolute coordinates.
+        // --> Turn it back into the absolute coordinates with the help of the old viewport.
+        coordCursor.y += srOldViewport.top;
 
         // Note that we allow the X coordinate to be outside the left border by 1 position,
         // because the cursor could still be visible if the focused character is double width.


Test patch: