Skip to content

Remove PSStyle if terminal does not support escape sequence #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 6, 2024

Conversation

@BethanyZhou BethanyZhou changed the title Update PSStyle.cs Remove PSStyle if does not support virtual terminal Aug 2, 2024
Comment on lines 340 to 343
if (null == PSStyle.SupportsVirtualTerminal)
{
PSStyle.SupportsVirtualTerminal = Host.UI.SupportsVirtualTerminal;
}
Copy link
Member

Choose a reason for hiding this comment

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

This logic is too specific to be put in AzurePSCmdlet. It should be in PSStyle.

Copy link
Contributor

Choose a reason for hiding this comment

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

Host.UI.SupportsVirtualTerminal is a property of PSCmdlet, its value is unavailable beyond cmdlet.

@@ -20,6 +20,8 @@ namespace Microsoft.WindowsAzure.Commands.Common
/// </summary>
public sealed class PSStyle
{
public static bool? SupportsVirtualTerminal = null;

/// <summary>
Copy link
Member

Choose a reason for hiding this comment

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

Try something like this

public static bool IsEscapeSequenceSupported {
  if (!_isEscapeSequenceSupported.HasValue) { _isEscapeSequenceSupported = Host.UI.SupportsVirtualTerminal; }
  return _isEscapeSequenceSupported.Value;
}
private static bool? _isEscapeSequenceSupported = null;

Copy link
Contributor

@BethanyZhou BethanyZhou Aug 2, 2024

Choose a reason for hiding this comment

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

good suggestion!

Copy link
Contributor

@dolauli dolauli left a comment

Choose a reason for hiding this comment

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

Do we need to add a change log somewhere for this change.

}

/// <summary>
/// This function should be invoked only in the Az.Accounts.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// This function should be invoked only in the Az.Accounts.
/// Initializes default settings of PSStyle according to the environment.
/// Note: This function should be invoked only in Az.Accounts.

@@ -20,6 +22,29 @@ namespace Microsoft.WindowsAzure.Commands.Common
/// </summary>
public sealed class PSStyle
{
private static bool? _isEscapeSequenceSupported = null;

public static bool IsEscapeSequenceSupported
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to make this public? Otherwise it can be private.

@BethanyZhou BethanyZhou changed the title Remove PSStyle if does not support virtual terminal Remove PSStyle if terminal does not support escape sequence Aug 5, 2024
@BethanyZhou
Copy link
Contributor

BethanyZhou commented Aug 5, 2024

Do we need to add a change log somewhere for this change.

@dolauli thanks for asking. No change log is needed for common repo. could you help approve this PR if no other comments.

@dolauli dolauli merged commit e57ee15 into Azure:main Aug 6, 2024
2 checks passed
@lijinpei2008 lijinpei2008 deleted the jinpei/enhancePSStyle branch August 6, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants