Use ProgressView.Classic if Virtual Terminal is not supported (#15048)

This commit is contained in:
Steve Lee
2021-04-12 16:40:29 -07:00
committed by GitHub
parent 8a3e02dcf7
commit 44d5ce9e01
@@ -48,7 +48,7 @@ namespace Microsoft.PowerShell
_pendingProgress = null;
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName) && PSStyle.Instance.Progress.UseOSCIndicator)
if (SupportsVirtualTerminal && ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName) && PSStyle.Instance.Progress.UseOSCIndicator)
{
// OSC sequence to turn off progress indicator
// https://github.com/microsoft/terminal/issues/6700
@@ -99,7 +99,7 @@ namespace Microsoft.PowerShell
{
// Update the progress pane only when the timer set up the update flag or WriteProgress is completed.
// As a result, we do not block WriteProgress and whole script and eliminate unnecessary console locks and updates.
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName) && PSStyle.Instance.Progress.UseOSCIndicator)
if (SupportsVirtualTerminal && ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName) && PSStyle.Instance.Progress.UseOSCIndicator)
{
int percentComplete = record.PercentComplete;
if (percentComplete < 0)
@@ -114,6 +114,12 @@ namespace Microsoft.PowerShell
Console.Write($"\x1b]9;4;1;{percentComplete}\x1b\\");
}
// If VT is not supported, we change ProgressView to classic
if (!SupportsVirtualTerminal && ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName))
{
PSStyle.Instance.Progress.View = ProgressView.Classic;
}
_progPane.Show(_pendingProgress);
}
}