Skip to content

Commit 4e2f72e

Browse files
On Windows, reset cursor visibility back to previous state when rendering progress (PowerShell#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>
1 parent c4555da commit 4e2f72e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,17 @@ private void WriteContent()
301301
{
302302
if (_content is not null)
303303
{
304+
// On Windows, we can check if the cursor is currently visible and not change it to visible
305+
// if it is intentionally hidden. On Unix, it is not currently supported to read the cursor visibility.
306+
#if UNIX
304307
Console.CursorVisible = false;
308+
#else
309+
bool currentCursorVisible = Console.CursorVisible;
310+
if (currentCursorVisible)
311+
{
312+
Console.CursorVisible = false;
313+
}
314+
#endif
305315

306316
var currentPosition = _rawui.CursorPosition;
307317
_rawui.CursorPosition = _location;
@@ -319,7 +329,11 @@ private void WriteContent()
319329
}
320330

321331
_rawui.CursorPosition = currentPosition;
332+
#if UNIX
322333
Console.CursorVisible = true;
334+
#else
335+
Console.CursorVisible = currentCursorVisible;
336+
#endif
323337
}
324338
}
325339

0 commit comments

Comments
 (0)