Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preserve empty lines between scss nested maps #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/language-css/printer-postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ function genericPrint(path, options, print) {
path.map((childPath, index) => {
const child = childPath.getValue();
const isLast = index === node.groups.length - 1;
const printed = [print(), isLast ? "" : ","];

let printed = [print(), isLast ? "" : ","];

// Key/Value pair in open paren already indented
if (
Expand All @@ -931,17 +932,22 @@ function genericPrint(path, options, print) {
) {
const parts = getDocParts(printed[0].contents.contents);
parts[1] = group(parts[1]);
return group(dedent(printed));
printed = [group(dedent(printed))];
}

if (
!isLast &&
child.type === "value-comma_group" &&
isNonEmptyArray(child.groups)
) {
const last = getLast(child.groups);
let last = getLast(child.groups);

// `value-paren_group` does not have location info, but its closing parenthesis does.
if (!last.source && last.close) {
last = last.close;
}

if (
// `value-paren_group` missing location info
last.source &&
isNextLineEmpty(options.originalText, last, locEnd)
) {
Expand Down
1 change: 1 addition & 0 deletions tests/format/scss/parens/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ $icons: (
left: 253,
top: 73,
),

/* Should preserve empty lines */ cal-week-group:
(
left: 1,
Expand Down