mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Remove the extra new line form List formatting (#18185)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user