Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInt

_pendingProgress = null;

if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName) && PSStyle.Instance.Progress.UseOSCIndicator)
if (SupportsVirtualTerminal && ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAnsiProgressFeatureName) && PSStyle.Instance.Progress.UseOSCIndicator)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why do not check SupportsVirtualTerminal in time we create PSStyle.Instance? It would seem be more generic.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the way we decide within the methods what behaviour to have here isn't great design and while this change seems ok, I think we need to register the need to do this better.

An alternative perspective on how the code should be structured: PSHostUserInterface is an abstract class intended to be overridden with the implementation to actually provide. The right object-oriented approach would be to build the user interface object for the given settings, with shared functionality implemented in a common base class.

{
// OSC sequence to turn off progress indicator
// https://github.com/microsoft/terminal/issues/6700
Expand Down Expand Up @@ -99,7 +99,7 @@ class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInt
{
// 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)
Expand All @@ -114,6 +114,12 @@ class ConsoleHostUserInterface : System.Management.Automation.Host.PSHostUserInt
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);
}
}
Expand Down