New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cursor shape gets reverted to legacy style after hiding the cursor and then making it visible again in console window #4124
Comments
Well, heck. |
As explained in #409, the problem is that calling the It's easy enough to "fix". We could just delete this line from the terminal/src/host/screenInfo.cpp Line 1778 in 6f667f4
But that's a change in behavior for a public API, and it's possible some applications could actually be relying on that behavior (although I would think that unlikely). Ideally the |
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.
🎉This issue was addressed in #5251, which has now been successfully released as Handy links: |
Environment
Steps to reproduce
After setting the cursor shape in
Properties->Terminal
, hiding and then showing the cursor by settingConsole.CursorVisible
tofalse
and thentrue
causes the cursor shape to be restored to the legacy style in console host.The following simple C# program can show the problem:
Expected behavior
Setting
Console.CursorVisible
should not revert the cursor shape.Actual behavior
The cursor shape gets reverted from
Solid Box
to the legacy style (Underline
):Related issues
#409 and #1145 and PowerShell/PSReadLine#903
Those 2 issues were reported in the PowerShell+PSReadLine context. PSReadLine depends on
Console.CursorVisible
to hide and show the cursor during rendering, so the cursor shape gets reverted.The text was updated successfully, but these errors were encountered: