Skip to content

Commit 8d905fd

Browse files
authored
fix: do not add empty line before the first section inside a region (#1298)
1 parent ace47fd commit 8d905fd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

client/testFixture/formatter/expected.sas

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@ quit;
8888

8989
%macro reportit(request);
9090
%if %upcase(&request)=STAT %then %do;
91-
9291
proc means;
9392
title "Summary of All Numeric Variables";
9493
run;
9594
%end;
9695
%else %if %upcase(&request)=PRINTIT %then %do;
97-
9896
proc print;
9997
title "Listing of Data";
10098
run;
@@ -105,7 +103,6 @@ quit;
105103

106104
*region;
107105
%macro;
108-
109106
*region;
110107
data _null_;
111108
*region;

server/src/sas/formatter/printer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ export const print: Printer<SASAST>["print"] = (path, options, print) => {
4545
);
4646
if (node.type === "region") {
4747
const region = printRegion(children);
48-
return !path.isFirst && node.block ? [hardline, ...region] : region;
48+
return !(
49+
path.isFirst ||
50+
(path.index === 1 && path.parent?.type === "region")
51+
) && node.block
52+
? [hardline, ...region]
53+
: region;
4954
}
5055
return [...join(line, children), literalline];
5156
}

0 commit comments

Comments
 (0)