File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -406,7 +406,7 @@ function Join-PipeScript
406
406
$blocks = @ ($AllScriptBlocks.Ast.EndBlock )
407
407
if ($blocks -ne $null ) {
408
408
$blockOpen = $false # see if there was anything in them.
409
-
409
+ $unnamedBlocks = @ ( $blocks .Unnamed )
410
410
foreach ($block in $blocks ) {
411
411
if (-not $block ) { continue }
412
412
# Empty(ish) scripts may have an end bock that is an empty param block
@@ -424,11 +424,12 @@ function Join-PipeScript
424
424
$blockOpen = $true
425
425
} elseif ($block.Statements.Count ) {
426
426
# where as if it is a series of statements, it doesn't necessarily need to be.
427
- # Unless it's the first block and it's unnamed.
428
- if ($block.Unnamed -and -not $blockOpen ) {
427
+ # Unless it's the first block and it's unnamed, and other blocks are named.
428
+ if ($block.Unnamed -and -not $blockOpen -and
429
+ $unnamedBlocks.Length -ne $blocks.Length ) {
429
430
' ' * ($block | MeasureIndent) + ' end {'
430
431
$blockOpen = $true
431
- $closeEndBlock = $true
432
+ $closeEndBlock = $false
432
433
}
433
434
if ($StatementsToAdd ) {
434
435
$StatementsToAdd -join [Environment ]::NewLine
You can’t perform that action at this time.
0 commit comments