New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid F# code when pattern matching on exception with long when guard and 2 space indentation #2784
Comments
Siema! Thank you for reporting this issue. This is an issue rather specific to the I think you can solve this by changing: fantomas/src/Fantomas.Core/CodePrinter.fs Lines 1247 to 1249 in 36b7325
into something that along the lines of: +> optSingle
(fun e ->
!- " when"
+> expressionFitsOnRestOfLine (sepSpace +> genExpr e) (fun ctx ->
// See https://github.com/fsprojects/fantomas/issues/2784
let doubleIndent = ctx.Config.IndentSize < 4
(indent
+> onlyIf doubleIndent indent
+> sepNln
+> genExpr e
+> unindent
+> onlyIf doubleIndent unindent)
ctx)) the idea is to just add a double indent when the Are you interested in submitting a PR for this? |
…double indent when the indent_size is lower than the default 4 spaces - fixes fsprojects#2784
Siema!
We do need to switch back to the default 4 indent size one day - 2 spaces might make the code more concise, but they encourage you to write more nested stuff and they make it harder to notice un-wanted whitespace fuckups like we had recently: by accident we moved a piece of logic after a while loop to the loop itself 🤦
I like it how it takes you more time to guide me how to fix it rather than fixing it yourself 😂 But I mean it - it just emphasises how good OSS maintainer you are by encouraging others to contribute! 👍
There you go! #2785 Side note: I'd consider adding a "fast-track" contributing section in https://fsprojects.github.io/fantomas/docs/contributors for busy dads: I appreciate all the rules and guidelines there are in order to contribute, but on the other hand if you had something like a "5 steps to fix a bug" section for a new comer, it could bring in more eager contributors :) |
Cześć! Thank you for these kind words 🤗. It may seem strange that I give you a near-working solution instead of just fixing it, but the idea is that we inspire you to save yourself. As this is an open-source project, you will always have the highest stakes in seeing your own problem fixed. I like the idea of a "fast-track" contributing section. We will give it some thought and see if we can come up with something. Great suggestion! |
Issue created from fantomas-online
Code
Result
Problem description
Extra information
Options
Fantomas v5.2 branch at 1/1/1990
Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?
The text was updated successfully, but these errors were encountered: