On Windows, reset cursor visibility back to previous state when rendering progress (#16782)

* On Windows, reset cursor visibility back to previous state when rendering progress

* Update src/Microsoft.PowerShell.ConsoleHost/host/msh/ProgressPane.cs

Co-authored-by: Ilya <darpa@yandex.ru>

Co-authored-by: Ilya <darpa@yandex.ru>
This commit is contained in:
Steve Lee
2022-05-13 15:21:18 -07:00
committed by GitHub
co-authored by Ilya
parent c4555da0ed
commit 4e2f72ea7d
@@ -301,7 +301,17 @@ namespace Microsoft.PowerShell
{
if (_content is not null)
{
// On Windows, we can check if the cursor is currently visible and not change it to visible
// if it is intentionally hidden. On Unix, it is not currently supported to read the cursor visibility.
#if UNIX
Console.CursorVisible = false;
#else
bool currentCursorVisible = Console.CursorVisible;
if (currentCursorVisible)
{
Console.CursorVisible = false;
}
#endif
var currentPosition = _rawui.CursorPosition;
_rawui.CursorPosition = _location;
@@ -319,7 +329,11 @@ namespace Microsoft.PowerShell
}
_rawui.CursorPosition = currentPosition;
#if UNIX
Console.CursorVisible = true;
#else
Console.CursorVisible = currentCursorVisible;
#endif
}
}