Closed tfausak closed 7 months ago
Sounds great! I like it! A nifty compromise.
This is pretty much the ormolu
approach: the user gets to choose (via the input) whether an element is formatted on one line or multiple lines, and then after that the tool decides how to format.
Released in version 1.2.0.0.
This would kind of address #20 and #28.
Currently Gild has one special case for formatting: If a field's value can be rendered on one line and has no comments attached, it will be rendered on the same line as the field. In other words:
Multiple people have requested a way for some fields to sometimes have their single-line value put on its own line even though it would normally go on the same line as the field name. For example:
I opted not to allow configuration for this and not to special case any field names for this.
I'm now wondering if there's a way out. In addition to the previous rules, what if Gild only formatted things on one line if the input was also on one line? To wit:
I typically prefer formatters that produce the same output for all inputs that map to the same AST. However this feels like relatively unsurprising behavior, and it would allow users to put single field values on their own lines if they wanted to.
I'm not sure how complicated this would be to support. Gild currently only uses positions to attach comments and re-flow free text (like in the
description
field).