-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Comment removed in multi-case pattern matching #813
Comments
The found comment is assigned to the And no trivia is generated around PatOr. Most likely enterNodeTokenByName before the pipe might do the trick. Check out this video to learn more about trivia. |
@nojaf Thank you for this project! This is my first time seeing this codebase, but I figured I could try tackling an issue, I had a test added in [<Test>]
let ``comments in pattern matching cases should not be removed, 813``() =
formatSourceString false """
let f (a: A) =
match a with
// comment for case A
| A
// comment for case C
| C -> Some()
| D -> Another() // inline comment
// comment for case _
| _ -> None""" config
|> prepend newline
|> should equal """
let f (a: A) =
match a with
// comment for case A
| A
// comment for case C
| C -> Some()
| D -> Another() // inline comment
// comment for case _
| _ -> None
""" and added | PatOr(p1, p2) ->
genPat astContext p1
+> enterNodeTokenByName pat.Range "BAR"
+> sepNln -- "| "
+> genPat astContext p2 so I went with | PatOr(p1, p2) ->
genPat astContext p1
+> enterNodeTokenByName pat.Range "BAR"
+> sepNone -- "| "
+> genPat astContext p2 but that may introduce its own issue I figure? |
Hello @kontomondo, thanks for your kind words. Could you maybe make a (draft) PR with this code? Then I can easily check it out and we can see if all the other tests still pass. |
@nojaf this issue should be closed since the PR is merged. |
It seems like the linking of the PR with the issue didn't happen alright. |
Issue created from fantomas-online
When there's a comment between two pattern matching cases that end in some branch, it gets removed
Code
Result
Options
Fantomas Next - 4.0.0-alpha-001-1/1/1990
IndentSpaceNum
4
PageWidth
120
SemicolonAtEndOfLine
false
SpaceBeforeParameter
true
SpaceBeforeLowercaseInvocation
true
SpaceBeforeUppercaseInvocation
false
SpaceBeforeClassConstructor
false
SpaceBeforeMember
false
SpaceBeforeColon
false
SpaceAfterComma
true
SpaceBeforeSemicolon
false
SpaceAfterSemicolon
true
IndentOnTryWith
false
SpaceAroundDelimiter
true
MaxIfThenElseShortWidth
40
MaxInfixOperatorExpression
50
MaxRecordWidth
40
MaxArrayOrListWidth
40
MaxLetBindingWidth
40
MultilineBlockBracketsOnSameColumn
false
NewlineBetweenTypeDefinitionAndMembers
false
StrictMode
false
The text was updated successfully, but these errors were encountered: