-
Notifications
You must be signed in to change notification settings - Fork 9k
Closed
Labels
Area-SettingsIssues related to settings and customizability, for console or terminalIssues related to settings and customizability, for console or terminalIssue-BugIt either shouldn't be doing this or needs an investigation.It either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsDoesn't match tag requirementsProduct-ConhostFor issues in the Console codebaseFor issues in the Console codebaseResolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.Fix is checked in, but it might be 3-4 weeks until a release.
Milestone
Description
Environment
Windows build number: Microsoft Windows [Version 10.0.18363.535]
Windows Terminal version (if applicable): NA
Any other software? No
Steps to reproduce
After setting the cursor shape in Properties->Terminal, hiding and then showing the cursor by setting Console.CursorVisible to false and then true causes the cursor shape to be restored to the legacy style in console host.
The following simple C# program can show the problem:
using System;
using System.Text;
namespace cursorShape
{
class Program
{
static void Main(string[] args)
{
const string prompt = "PROMP> ";
StringBuilder sb = new StringBuilder();
int top = Console.CursorTop;
Console.OutputEncoding = Encoding.UTF8;
Console.Write(prompt);
while (true)
{
var key = Console.ReadKey();
if (key.Key == ConsoleKey.Q)
{
break;
}
sb.Append(key.KeyChar);
Console.CursorVisible = false; // Hide the cursor before rewriting
Console.SetCursorPosition(0, top);
Console.Write($"{prompt}{sb}");
Console.SetCursorPosition(Console.CursorLeft, top);
Console.CursorVisible = true; // Show the cursor afterwards
}
}
}
}
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.
Metadata
Metadata
Assignees
Labels
Area-SettingsIssues related to settings and customizability, for console or terminalIssues related to settings and customizability, for console or terminalIssue-BugIt either shouldn't be doing this or needs an investigation.It either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsDoesn't match tag requirementsProduct-ConhostFor issues in the Console codebaseFor issues in the Console codebaseResolution-Fix-CommittedFix is checked in, but it might be 3-4 weeks until a release.Fix is checked in, but it might be 3-4 weeks until a release.