Do not break before `+` (#1777)

We really want to parse those as binary expressions but it's not going to be trivial. A quick fix that should help is to not break before those.
master
Christopher Chedeau 2017-05-27 13:41:19 -07:00 committed by GitHub
parent 122bb65f16
commit 6f72e278e9
3 changed files with 14 additions and 1 deletions

View File

@ -2648,9 +2648,16 @@ function genericPrintNoParens(path, options, print, args) {
n.groups[i + 1].raws && n.groups[i + 1].raws &&
n.groups[i + 1].raws.before !== "" n.groups[i + 1].raws.before !== ""
) { ) {
if (
n.groups[i + 1].type === "value-operator" &&
["+", "-", "/", "*", "%"].indexOf(n.groups[i + 1].value) !== -1
) {
parts.push(" ");
} else {
parts.push(line); parts.push(line);
} }
} }
}
return group(indent(concat(parts))); return group(indent(concat(parts)));
} }

View File

@ -4,6 +4,7 @@ exports[`indent.css 1`] = `
div { div {
background: var(fig-light-02) url(/images/inset-shadow-east-ltr.png) 100% 0 repeat-y; background: var(fig-light-02) url(/images/inset-shadow-east-ltr.png) 100% 0 repeat-y;
box-shadow: 0 0 1px 2px rgba(88, 144, 255, 0.75), 0 1px 1px rgba(0, 0, 0, 0.15); box-shadow: 0 0 1px 2px rgba(88, 144, 255, 0.75), 0 1px 1px rgba(0, 0, 0, 0.15);
padding-bottom: calc(var(ads-help-tray-footer-with-support-link-height) + var(ads-help-tray-header-height-new));
} }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
div { div {
@ -14,6 +15,10 @@ div {
repeat-y; repeat-y;
box-shadow: 0 0 1px 2px rgba(88, 144, 255, 0.75), box-shadow: 0 0 1px 2px rgba(88, 144, 255, 0.75),
0 1px 1px rgba(0, 0, 0, 0.15); 0 1px 1px rgba(0, 0, 0, 0.15);
padding-bottom: calc(
var(ads-help-tray-footer-with-support-link-height) +
var(ads-help-tray-header-height-new)
);
} }
`; `;

View File

@ -1,4 +1,5 @@
div { div {
background: var(fig-light-02) url(/images/inset-shadow-east-ltr.png) 100% 0 repeat-y; background: var(fig-light-02) url(/images/inset-shadow-east-ltr.png) 100% 0 repeat-y;
box-shadow: 0 0 1px 2px rgba(88, 144, 255, 0.75), 0 1px 1px rgba(0, 0, 0, 0.15); box-shadow: 0 0 1px 2px rgba(88, 144, 255, 0.75), 0 1px 1px rgba(0, 0, 0, 0.15);
padding-bottom: calc(var(ads-help-tray-footer-with-support-link-height) + var(ads-help-tray-header-height-new));
} }