Support automatic line breaking at column limit#305
Support automatic line breaking at column limit#305brandonchinn178 merged 3 commits intofourmolu:mainfrom
Conversation
|
👋 @CrystalSplitter Reviewer: Please verify the following things have been done, if applicable.
|
data/examples/declaration/rewrite-rule/prelude1-line-break-out.hs
Outdated
Show resolved
Hide resolved
bc3d0c5 to
c09315d
Compare
74fad4a to
8ec7a16
Compare
brandonchinn178
left a comment
There was a problem hiding this comment.
Small nits, let me know if you agree, or I can merge as-is
6b8d84b to
68cf957
Compare
brandonchinn178
left a comment
There was a problem hiding this comment.
One last nit. Feel free to ignore.
68cf957 to
c9e8a46
Compare
|
Hold on, parsing issue.
May have broken it somewhere in my fixups... |
|
@CrystalSplitter the adtParseJson implementation, I think. Also, the tests apparently dont test that function... I'll have to think about how best to test it |
|
The underlying issue here is that column limit can both be a Some solutions:
|
|
Or just parse it directly? parseJson = \case
String "none" -> pure NoLimit
Number x | Right i <- floatingOrIntegral x -> pure $ ColumnLimit i
_ -> fail "Invalid ColumnLimit"It'll slightly duplicate the adtParseText implementation, which I think is fine. |
c9e8a46 to
d3b7a58
Compare
|
Done, but I had to include |
d3b7a58 to
67ddfe9
Compare
This feature is implemented as a hack, as described by George Thomas in Issue fourmolu#71. Unfortunately, adding a column limit/max line length right now is not idempotent. We mark the feature with a warning accordingly in the README. The actual logic changes of this commit are in: * Ormolu/Printer/Combinators.hs * Ormolu/Printer/Meat/Declaration/Value.hs The rest is config changes, to surface this option. Co-authored-by: CrystalSplitter <gamewhizzit@gmail.com>
We have to configure tests to ignore idempotency in the PrinterOptsSpec, so we have to interpret examples based on TestGroup context This makes use of the existing input/output fourmolu testing configuration. Co-authored-by: Gustavo Avena <ggavena@gmail.com>
67ddfe9 to
87d394d
Compare
This is a revival of the work done in #102 by @gustavoavena
This feature is implemented as a hack, as described by @georgefst in Issue #71.
This breaks idempotency, which is an unfortunate limitation of this implementation. Open to making fixes for idempotency, but from the comments in #71, this seems to be okay given the utility and the warning.