Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2430,6 +2430,14 @@ internal void Run(bool inputLoopIsNested)

while (!_parent.ShouldEndSession && !_shouldExit)
{
#if !UNIX
if (ui.SupportsVirtualTerminal)
{
// need to re-enable VT mode if it was previously enabled as native commands may have turned it off
ui.TryTurnOnVtMode();
}
#endif

try
{
_parent._isRunningPromptLoop = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ internal ConsoleHostUserInterface(ConsoleHost parent)

_parent = parent;
_rawui = new ConsoleHostRawUserInterface(this);
SupportsVirtualTerminal = TryTurnOnVtMode();
_isInteractiveTestToolListening = false;
}

internal bool TryTurnOnVtMode()
{
#if UNIX
SupportsVirtualTerminal = true;
return true;
#else
try
{
Expand All @@ -76,15 +81,16 @@ internal ConsoleHostUserInterface(ConsoleHost parent)
// We only know if vt100 is supported if the previous call actually set the new flag, older
// systems ignore the setting.
m = ConsoleControl.GetMode(handle);
this.SupportsVirtualTerminal = (m & ConsoleControl.ConsoleModes.VirtualTerminal) != 0;
return (m & ConsoleControl.ConsoleModes.VirtualTerminal) != 0;
}
}
catch
{
// Do nothing if failed
}
#endif

_isInteractiveTestToolListening = false;
return false;
#endif
}

/// <summary>
Expand Down