Skip to content

Commit b3abee1

Browse files
Make Out-ConsoleGridView fail gracefully in remote session (#124)
* Fail gracefully if in remote session * Revert "Fail gracefully if in remote session" This reverts commit 57e5968. * Prevent unexpected exit from remote session * Revert "Prevent unexpected exit from remote session" This reverts commit 6bdb9d5. * Prevent unexpected exit from remote session Do not set cursor key to application mode if cmdlet is in remote session * Update src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs Co-authored-by: Tyler James Leonhardt <[email protected]> Co-authored-by: Tyler James Leonhardt <[email protected]>
1 parent 6e8fb2f commit b3abee1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,14 @@ private void AddRows(Window win)
320320

321321
public void Dispose()
322322
{
323-
// By emitting this, we fix an issue where arrow keys don't work in the console
324-
// because .NET requires application mode to support Arrow key escape sequences
325-
// Esc[?1h - Set cursor key to application mode
326-
// See http://ascii-table.com/ansi-escape-sequences-vt-100.php
327-
Console.Write("\u001b[?1h");
323+
if (!Console.IsInputRedirected)
324+
{
325+
// By emitting this, we fix an issue where arrow keys don't work in the console
326+
// because .NET requires application mode to support Arrow key escape sequences
327+
// Esc[?1h - Set cursor key to application mode
328+
// See http://ascii-table.com/ansi-escape-sequences-vt-100.php
329+
Console.Write("\u001b[?1h");
330+
}
328331
}
329332
}
330333
}

0 commit comments

Comments
 (0)