[PR #5551] [MERGED] Lock when changing selection endpoint on wheel/auto-scroll #26368

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5551
Author: @miniksa
Created: 4/24/2020
Status: Merged
Merged: 4/24/2020
Merged by: @DHowett-MSFT

Base: masterHead: dev/miniksa/racey_mcgee


📝 Commits (1)

  • f5c8b0b Take the lock before moving the selection endpoint out from under the renderer while it's rendering a frame.

📊 Changes

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

View changed files

📝 src/cascadia/TerminalControl/TermControl.cpp (+6 -0)

📄 Description

Summary of the Pull Request

Takes the lock inside two routines in TermControl that were changing the selection endpoint while a rendering frame was still drawing, resulting in several variants of graphical glitches from double-struck selection boxes to duplicated line text.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

The renderer base and specific renderer engine do a lot of work to remember the previous selection and compensate for scrolling regions and deltas between frames. However, all that work doesn't quite match up when the endpoints are changed out from under it. Unfortunately, TermControl doesn't have a robust history of locking correctly in step with the renderer nor does the renderer's IRenderData currently provide any way of 'snapping' state at the beginning of a frame so it could work without a full lock. So the solution for now is for the methods that scroll the display in TermControl to take the lock that is shared with the renderer's frame painter so they can't change out of sync.

Validation Steps Performed

  • - Opened terminal with Powershell core. Did ls a bunch of times. Clicked to make selection and held mouse button while wheeling around.
  • - Opened terminal with Powershell core. Did ls a bunch of times. Clicked to make selection and dragged mouse outside the window to make auto scroll happen.
  • - Opened terminal with Powershell core. Did ls a bunch of times. Clicked to make selection and released. Wheeled around like a crazy person to make sure I didn't regress that.

🔄 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/5551 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 4/24/2020 **Status:** ✅ Merged **Merged:** 4/24/2020 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `dev/miniksa/racey_mcgee` --- ### 📝 Commits (1) - [`f5c8b0b`](https://github.com/microsoft/terminal/commit/f5c8b0bca0b9edd1be404817a3cb871b98db8668) Take the lock before moving the selection endpoint out from under the renderer while it's rendering a frame. ### 📊 Changes **1 file changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+6 -0) </details> ### 📄 Description ## Summary of the Pull Request Takes the lock inside two routines in `TermControl` that were changing the selection endpoint while a rendering frame was still drawing, resulting in several variants of graphical glitches from double-struck selection boxes to duplicated line text. ## References - Introduced with #5185 ## PR Checklist * [x] Closes #5471 * [x] Already signed life away to company. * [x] Manual tests passed since it's visual. * [x] No extra doc besides the comments. * [x] Am core contributor: Roar. ## Detailed Description of the Pull Request / Additional comments The renderer base and specific renderer engine do a lot of work to remember the previous selection and compensate for scrolling regions and deltas between frames. However, all that work doesn't quite match up when the endpoints are changed out from under it. Unfortunately, `TermControl` doesn't have a robust history of locking correctly in step with the renderer nor does the renderer's `IRenderData` currently provide any way of 'snapping' state at the beginning of a frame so it could work without a full lock. So the solution for now is for the methods that scroll the display in `TermControl` to take the lock that is shared with the renderer's frame painter so they can't change out of sync. ## Validation Steps Performed - [x] - Opened terminal with Powershell core. Did ls a bunch of times. Clicked to make selection and held mouse button while wheeling around. - [x] - Opened terminal with Powershell core. Did ls a bunch of times. Clicked to make selection and dragged mouse outside the window to make auto scroll happen. - [x] - Opened terminal with Powershell core. Did ls a bunch of times. Clicked to make selection and released. Wheeled around like a crazy person to make sure I didn't regress that. --- <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:15:38 +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#26368