Skip to content

Commit

Permalink
fix: do not add empty line before the first section inside a region (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
scnwwu authored Nov 29, 2024
1 parent ace47fd commit 8d905fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 0 additions & 3 deletions client/testFixture/formatter/expected.sas
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,11 @@ quit;

%macro reportit(request);
%if %upcase(&request)=STAT %then %do;

proc means;
title "Summary of All Numeric Variables";
run;
%end;
%else %if %upcase(&request)=PRINTIT %then %do;

proc print;
title "Listing of Data";
run;
Expand All @@ -105,7 +103,6 @@ quit;

*region;
%macro;

*region;
data _null_;
*region;
Expand Down
7 changes: 6 additions & 1 deletion server/src/sas/formatter/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export const print: Printer<SASAST>["print"] = (path, options, print) => {
);
if (node.type === "region") {
const region = printRegion(children);
return !path.isFirst && node.block ? [hardline, ...region] : region;
return !(
path.isFirst ||
(path.index === 1 && path.parent?.type === "region")
) && node.block
? [hardline, ...region]
: region;
}
return [...join(line, children), literalline];
}
Expand Down

0 comments on commit 8d905fd

Please sign in to comment.