azure-dev icon indicating copy to clipboard operation
azure-dev copied to clipboard

Make text formatting less fragile on Windows

Open weikanglim opened this issue 3 years ago • 0 comments

Currently, to format text, we need to both:

  • Add styling around text that requires formatting
  • Ensure that any print that consumes the formatted text uses printWithStyling. Otherwise, it does not work on Windows.

We want a solution that ensures we support other Windows 10 and up users, while providing a reasonable experience on older Windows versions:

  • Enable ENABLE_VIRTUAL_TERMINAL_PROCESSING by default. We can check the return code to see if the feature isn't supported for the particular version of Windows.
  • If virtual terminal processing isn't supported, we simply set color.NoColor to true, effectively disabling all color output. That way, users do not see escape characters show up in their console, has a reasonable experience, and we also don't eat the cost of maintaining this largely deprecated path.

Originally posted by @weikanglim in https://github.com/Azure/azure-dev/pull/208#discussion_r933603350

weikanglim avatar Aug 01 '22 16:08 weikanglim