mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Re-enable VT mode on Windows after running command in ConsoleHost (#14413)
This commit is contained in:
@@ -2430,6 +2430,14 @@ namespace Microsoft.PowerShell
|
||||
|
||||
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;
|
||||
|
||||
@@ -60,9 +60,14 @@ namespace Microsoft.PowerShell
|
||||
|
||||
_parent = parent;
|
||||
_rawui = new ConsoleHostRawUserInterface(this);
|
||||
SupportsVirtualTerminal = TryTurnOnVtMode();
|
||||
_isInteractiveTestToolListening = false;
|
||||
}
|
||||
|
||||
internal bool TryTurnOnVtMode()
|
||||
{
|
||||
#if UNIX
|
||||
SupportsVirtualTerminal = true;
|
||||
return true;
|
||||
#else
|
||||
try
|
||||
{
|
||||
@@ -76,15 +81,16 @@ namespace Microsoft.PowerShell
|
||||
// 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>
|
||||
|
||||
Reference in New Issue
Block a user