mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix Format-Table -RepeatHeader for property derived tables (#18870)
This commit is contained in:
@@ -223,6 +223,7 @@ namespace Microsoft.PowerShell.Commands.Internal.Format
|
||||
TableHeaderInfo thi = new TableHeaderInfo();
|
||||
|
||||
thi.hideHeader = this.HideHeaders;
|
||||
thi.repeatHeader = this.RepeatHeader;
|
||||
|
||||
for (int k = 0; k < this.activeAssociationList.Count; k++)
|
||||
{
|
||||
|
||||
@@ -813,6 +813,14 @@ A Name B
|
||||
($lines | Select-String "Name\s*Value").Count | Should -Be ($numHeaders + 1)
|
||||
}
|
||||
|
||||
It "-RepeatHeader should output the header at every screen full for custom table" -Skip:([Console]::WindowHeight -eq 0) {
|
||||
$numHeaders = 4
|
||||
$numObjects = [Console]::WindowHeight * $numHeaders
|
||||
$out = 1..$numObjects | ForEach-Object { [pscustomobject]@{foo=$_;bar=$_;hello=$_;world=$_} } | Format-Table -Property hello, world -RepeatHeader | Out-String
|
||||
$lines = $out.Split([System.Environment]::NewLine)
|
||||
($lines | Select-String "Hello\s*World").Count | Should -Be ($numHeaders + 1)
|
||||
}
|
||||
|
||||
It "Should be formatted correctly if width is declared and using center alignment" {
|
||||
$expectedTable = @"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user