Remove the extra new line form List formatting (#18185)

This commit is contained in:
Dongbo Wang
2022-09-30 15:47:51 -07:00
committed by GitHub
parent d9d6b7f8de
commit a7a49290a8
2 changed files with 11 additions and 6 deletions
@@ -456,9 +456,16 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
/// <param name="c">Current context, with Fs in it.</param>
private void ProcessFormatEnd(FormatEndData fe, FormatMessagesContextManager.OutputContext c)
{
// Console.WriteLine("ProcessFormatEnd");
// we just add an empty line to the display
this.LineOutput.WriteLine(string.Empty);
if (c is FormatOutputContext foContext
&& foContext.Data.shapeInfo is ListViewHeaderInfo)
{
// Skip writing out a new line for List view, because we already wrote out
// an extra new line after displaying the last list entry.
return;
}
// We just add an empty line to the display.
LineOutput.WriteLine(string.Empty);
}
/// <summary>
@@ -37,7 +37,7 @@ Describe "Format-List" -Tags "CI" {
}
It "Should produce the expected output" {
$expected = "${nl}testName : testValue${nl}${nl}${nl}"
$expected = "${nl}testName : testValue${nl}${nl}"
$in = New-Object PSObject
Add-Member -InputObject $in -MemberType NoteProperty -Name testName -Value testValue
@@ -201,7 +201,6 @@ dbda : KM
消息 : 千
"@
$expected = $expected -replace "`r`n", "`n"
@@ -224,7 +223,6 @@ float : 9876.543
decimal : 4567.123456789
"@
$actual = $o | Format-List | Out-String