[PR #5251] [MERGED] Prevent the cursor type being reset when changing the visibility #26208

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5251
Author: @j4james
Created: 4/6/2020
Status: Merged
Merged: 4/7/2020
Merged by: @DHowett-MSFT

Base: masterHead: fix-cursor-type-reset


📝 Commits (1)

  • a0fac74 Prevent the cursor type being reset to the Legacy style if only the visibility is being changed.

📊 Changes

1 file changed (+9 additions, -1 deletions)

View changed files

📝 src/host/screenInfo.cpp (+9 -1)

📄 Description

A side effect of the SetConsoleCursorInfo API is that it resets the
cursor type to Legacy. This makes it impossible to change the cursor
visibility via the console APIs without also resetting the user's
preferred cursor type. This PR attempts to fix that limitation, by only
resetting the cursor type if the size has also been changed.

PR Checklist

Detailed Description of the Pull Request / Additional comments

I suspect the reason for the original behaviour was because the
SetConsoleCursorInfo API sets both the visibility and the size, and if
you're setting the size, it's assumed you'd want the Legacy cursor
type, because that's the only style for which the size is applicable.

So my solution was to only reset the cursor type if the requested cursor
size was actually different from the current size. That should be
reasonably backwards compatible with most size-changing code, but also
allow for changing the visibility without resetting the cursor type.

Validation Steps Performed

I've tested the example code from issue #4124, and confirmed that it now
works correctly without resetting the cursor type.

I've also tested the console's mark mode, which temporarily changes
the cursor size while selecting. I've confirmed that the size still
changes, and that the original cursor type is restored afterwards.


🔄 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/5251 **Author:** [@j4james](https://github.com/j4james) **Created:** 4/6/2020 **Status:** ✅ Merged **Merged:** 4/7/2020 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `fix-cursor-type-reset` --- ### 📝 Commits (1) - [`a0fac74`](https://github.com/microsoft/terminal/commit/a0fac74f77014d1f64920ef5529fde095604146c) Prevent the cursor type being reset to the Legacy style if only the visibility is being changed. ### 📊 Changes **1 file changed** (+9 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/host/screenInfo.cpp` (+9 -1) </details> ### 📄 Description A side effect of the `SetConsoleCursorInfo` API is that it resets the cursor type to _Legacy_. This makes it impossible to change the cursor visibility via the console APIs without also resetting the user's preferred cursor type. This PR attempts to fix that limitation, by only resetting the cursor type if the size has also been changed. ## PR Checklist * [x] Closes #4124 * [x] CLA signed * [ ] Tests added/passed * [ ] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments I suspect the reason for the original behaviour was because the `SetConsoleCursorInfo` API sets both the visibility and the size, and if you're setting the size, it's assumed you'd want the _Legacy_ cursor type, because that's the only style for which the size is applicable. So my solution was to only reset the cursor type if the requested cursor size was actually different from the current size. That should be reasonably backwards compatible with most size-changing code, but also allow for changing the visibility without resetting the cursor type. ## Validation Steps Performed I've tested the example code from issue #4124, and confirmed that it now works correctly without resetting the cursor type. I've also tested the console's _mark mode_, which temporarily changes the cursor size while selecting. I've confirmed that the size still changes, and that the original cursor type is restored afterwards. --- <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:14: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#26208