Adjust heuristic for fun-decl body placement#88
Adjust heuristic for fun-decl body placement#88MatthewFluet wants to merge 2 commits intoshwestrick:mainfrom
Conversation
|
One downside of removing the - fun new () =
- let val result = DocVar {id = !counter}
- in counter := !counter + 1; result
- end
+ fun new () = let val result = DocVar {id = !counter}
+ in counter := !counter + 1; result
+ endOf course, as you point out in #82, this is inconsistent with how This makes me think that we need a heuristic to avoid awkward splitting. And, if we had this heuristic, then the same splitting logic could be used for both Thoughts? |
|
The issue with rightward drift makes sense. Agreed that a heuristic that avoids the awkward splitting and is consistent with both I think that the issue with The informal heuristic would seem to be that if the entire expression can be printed on the same line as the |
Don't force "biggish" fun-decl-body expressions onto new line.
Fixes #82
While this addresses the main issue raised by #82, it does not exactly replicate the logic of
valdecls. I tried doing something closer toPrettierExpAndDec.sml#L815:L817, with ashowClauseSplittablethat usescondandsplitShowExpLeft/splitShowExpRight, but I found theisSplittablecondition forAppto frequently leave a single token on thefunline after the=token, followed by a much larger expression on the next line, which often looked awkward if not outright misleading; for example:or