@@ -1359,7 +1359,12 @@ proc infixArgument(g: var TOutput, n: PNode, i: int, flags: SubFlags) =
13591359 put (g, tkParRi, " )" )
13601360
13611361proc postStatements (
1362- g: var TOutput , n: PNode , start: int , skipDo: bool , skipColon = false
1362+ g: var TOutput ,
1363+ n: PNode ,
1364+ start: int ,
1365+ skipDo: bool ,
1366+ skipColon = false ,
1367+ skipMids = true ,
13631368) =
13641369 # Sometimes, `do` can be skipped but it is not entirely clear when - this
13651370 # feature rests on experiments with large codebases but should be researched
@@ -1378,6 +1383,9 @@ proc postStatements(
13781383 elif not skipColon:
13791384 putWithSpace (g, tkColon, " :" )
13801385
1386+ if not skipMids:
1387+ gmids (g, n)
1388+
13811389 gsub (g, n[i])
13821390
13831391 i.inc
@@ -1483,7 +1491,8 @@ proc gsub(g: var TOutput, n: PNode, flags: SubFlags, extra: int) =
14831491 g, n, tkParLe, start = 1 , theEnd = i - 1 - n.len, flags = {lfLongSepAtEnd}
14841492 )
14851493
1486- postStatements (g, n, i, sfSkipDo in flags)
1494+ postStatements (g, n, i, sfSkipDo in flags, skipMids = i > 1 )
1495+
14871496 dedent (g, ind)
14881497
14891498 if n.lastSon.kind == nkDo and sfParDo in flags:
@@ -1561,7 +1570,9 @@ proc gsub(g: var TOutput, n: PNode, flags: SubFlags, extra: int) =
15611570 # ":" is present so it looks like we can skip the `do` here :/ this needs
15621571 # deeper investigation - see also `nkPar` which sometimes removes the
15631572 # parenthesis from the AST
1564- postStatements (g, n, i, sfSkipDo in flags, n[i].kind == nkStmtListExpr)
1573+ postStatements (
1574+ g, n, i, sfSkipDo in flags, n[i].kind == nkStmtListExpr, skipMids = false
1575+ )
15651576 else :
15661577 # The first argument must not be line-broken, or command syntax breaks!
15671578 if n.len > 1 :
0 commit comments