[PR #12094] [MERGED] Initialize cursorOn to match focus state #28836

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12094
Author: @zadjii-msft
Created: 1/5/2022
Status: Merged
Merged: 1/10/2022
Merged by: @undefined

Base: mainHead: dev/migrie/b/11411-cursor-visibility


📝 Commits (1)

  • 9e60649 I've opened 900 tabs now and I'm sure that this works

📊 Changes

1 file changed (+10 additions, -2 deletions)

View changed files

📝 src/cascadia/TerminalControl/TermControl.cpp (+10 -2)

📄 Description

I'm not 100% sure that this is the right solution, but it does seem to work well enough. This is unfortunately a classic heisenbug. It was already hard enough to repro originally, but attaching a debugger made it totally impossible to hit.

My theory is that it's possible for the GotFocus event to fire before the LayoutUpdated event does. If that were to occur, then we'd try to turn on the cursor timer before it exists, gracefully do nothing, then create the timer. In that case, we'd never get a subsequent message to start the blinking.

I tested that theory by just initializing the cursor blinker to our _focused state. In that case, if the control has already been focused at the time of the LayoutUpdated event, then we can init the cursor to the correct state. Testing that out, I couldn't once get this to repro, which makes me think this works. I've opened some 900 (hyperbole) tabs now, so I'm pretty confident I'd have seen it by now.


🔄 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/12094 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 1/5/2022 **Status:** ✅ Merged **Merged:** 1/10/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/b/11411-cursor-visibility` --- ### 📝 Commits (1) - [`9e60649`](https://github.com/microsoft/terminal/commit/9e606492099150a2c2bd9e275342cc42e6e7fff4) I've opened 900 tabs now and I'm sure that this works ### 📊 Changes **1 file changed** (+10 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+10 -2) </details> ### 📄 Description I'm not 100% sure that this is the right solution, but it does seem to work well enough. This is unfortunately a classic heisenbug. It was already hard enough to repro originally, but attaching a debugger made it totally impossible to hit. My theory is that it's possible for the GotFocus event to fire before the LayoutUpdated event does. If that were to occur, then we'd try to turn on the cursor timer before it exists, gracefully do nothing, then create the timer. In that case, we'd never get a subsequent message to start the blinking. I tested that theory by just initializing the cursor blinker to our `_focused` state. In that case, if the control has already been focused at the time of the LayoutUpdated event, then we can init the cursor to the correct state. Testing that out, I couldn't once get this to repro, which makes me think this works. I've opened some 900 (<sup>hyperbole</sup>) tabs now, so I'm pretty confident I'd have seen it by now. * Regressed in #10978 * [x] fixes #11411 * [x] I made sure I didn't regress #6586 * [x] I work here --- <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:31:05 +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#28836