mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix PlainText output to correctly remove Reset VT sequence w/o number (#19283)
This commit is contained in:
@@ -98,7 +98,7 @@ namespace System.Management.Automation.Internal
|
||||
}
|
||||
|
||||
// graphics/color mode ESC[1;2;...m
|
||||
private const string GraphicsRegex = @"(\x1b\[\d+(;\d+)*m)";
|
||||
private const string GraphicsRegex = @"(\x1b\[\d*(;\d+)*m)";
|
||||
|
||||
// CSI escape sequences
|
||||
private const string CsiRegex = @"(\x1b\[\?\d+[hl])";
|
||||
|
||||
@@ -81,11 +81,11 @@ Describe 'OutputRendering tests' -Tag 'CI' {
|
||||
}
|
||||
|
||||
It 'ToString(OutputRendering) works correctly' {
|
||||
$s = [System.Management.Automation.Internal.StringDecorated]::new($PSStyle.Foreground.Red + 'Hello')
|
||||
$s = [System.Management.Automation.Internal.StringDecorated]::new($PSStyle.Foreground.Red + "Hello`e[m.")
|
||||
$s.IsDecorated | Should -BeTrue
|
||||
$s.ToString() | Should -BeExactly "$($PSStyle.Foreground.Red)Hello"
|
||||
$s.ToString([System.Management.Automation.OutputRendering]::ANSI) | Should -BeExactly "$($PSStyle.Foreground.Red)Hello"
|
||||
$s.ToString([System.Management.Automation.OutputRendering]::PlainText) | Should -BeExactly 'Hello'
|
||||
$s.ToString() | Should -BeExactly "$($PSStyle.Foreground.Red)Hello`e[m."
|
||||
$s.ToString([System.Management.Automation.OutputRendering]::ANSI) | Should -BeExactly "$($PSStyle.Foreground.Red)Hello`e[m."
|
||||
$s.ToString([System.Management.Automation.OutputRendering]::PlainText) | Should -BeExactly 'Hello.'
|
||||
{ $s.ToString([System.Management.Automation.OutputRendering]::Host) } | Should -Throw -ErrorId 'ArgumentException'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user