Skip to content

Commit

Permalink
Fixes bug in call stack enumeration with nested functions containing …
Browse files Browse the repository at this point in the history
…`Section -Orientation` definitions (#121)
  • Loading branch information
iainbrighton committed Jun 17, 2023
1 parent 55f76d9 commit 572513f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Adds custom list number formats (Word and Text plugins only)
* Adds `NumberStyle` keyword
* Fixes bug in Text table output breaking Word and Html output (#126)
* Fixes bug in call stack enumeration with nested functions containing `Section -Orientation` definitions (#121)

### 0.10.0 ###

Expand Down
5 changes: 3 additions & 2 deletions Src/Private/New-PScriboSection.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ function New-PScriboSection
)
begin
{
$psCallStack = Get-PSCallStack | Where-Object { $_.FunctionName -ne '<ScriptBlock>' }
if ($PSBoundParameters.ContainsKey('Orientation') -and ($psCallStack[2].FunctionName -ne 'Document<Process>'))
## Ensure we only have one 'Section' in the call stack (#121)
$psCallStack = @(Get-PSCallStack | Where-Object { $_.FunctionName -eq 'Section<Process>' })
if ($PSBoundParameters.ContainsKey('Orientation') -and ($psCallStack.Count -gt 1))
{
Write-PScriboMessage -Message $localized.CannotSetOrientationWarning -IsWarning;
$null = $PSBoundParameters.Remove('Orientation')
Expand Down

0 comments on commit 572513f

Please sign in to comment.