lukeed/tidyPublic

fix: stable member chain layout

When an object in a chain's last call breaks, the next formatting
finds it broken and keeps it so, and may then put the chain on one
line. A new best-fitting fallback prints the expanded chain unless
such a group breaks in it; then it measures the one-line chain with
that group and the groups and variants around it broken, as the next
formatting does, and prints it if it fits. Prettier's fixed point in
one pass (js-stable-output), at no measurable cost.

Also: the parentheses that wrap a template's expression aren't the
source's, so a comment in them stays put. The embedded oracle accepts
Prettier's fixed point.
LELuke Edwards authored
7c0dcc2Patch
Parent2762356
7 files changed+203-6
StackedSplit
crates/tidy/src/js/ast/comments.rs+2 −0
crates/tidy/src/js/ir/element.rs+4 −0
crates/tidy/src/js/ir/printer/measure.rs+16 −2
crates/tidy/src/js/ir/printer/mod.rs+130 −1
crates/tidy/src/js/utils/member_chain/mod.rs+25 −1
crates/tidy/tests/js.rs+12 −0
tests/oracle/embedded.ts+14 −2