PowerShell / ConsoleGuiTools

Modules that mix PowerShell and GUIs/CUIs!
https://www.powershellgallery.com/packages/Microsoft.PowerShell.ConsoleGuiTools
MIT License
776 stars 59 forks source link

Fixes #131 - Out-ConsoleGridView doesn't handle ANSI escape sequences correctly #154

Closed tig closed 2 years ago

tig commented 2 years ago

This PR Fixes #131

Previous to PowerShell 7.1, it would have been uncommon for a cmdlet to receive input decorated with ANSI escape sequences. But support for ANSI was added in 7.1 (see https://github.com/PowerShell/PowerShell/issues/13071).

This PR adds a single line of code, a RegEx, to strip ANSI escape sequences from the input text.

This PR is a draft because

a) A regex is probably not the most robust way to strip ANSI. Apparently PS has a built-in capability (StringDecorated) but that is internal. b) Pulling in all of Regex is overkill probably c) I'm not 100% certain that TypeGetter.cs is the right place to do the stripping.

Comments appreciated.