Skip to content

Commit

Permalink
fix idempotency issue by adding a conditional newline after the pats
Browse files Browse the repository at this point in the history
  • Loading branch information
dawedawe committed Dec 20, 2023
1 parent 09b0b5b commit cd04b16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Fantomas.Core.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,8 @@ Some ident.idRange
equal
"""
match synExpr with
| SynExpr.App(argExpr = SynExpr.Match _) -> // CCC
Some ident.idRange
| SynExpr.App(
argExpr = SynExpr.Match _ // CCC
) -> Some ident.idRange
| _ -> defaultTraverse synExpr
"""
6 changes: 5 additions & 1 deletion src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,11 @@ let genPat (p: Pattern) =
+> optSingle genTyparDecls node.TyparDecls
+> addSpaceBeforeParenInPattern node.Identifier
+> genSingleTextNode node.OpeningParen
+> autoIndentAndNlnIfExpressionExceedsPageWidth (sepNlnWhenWriteBeforeNewlineNotEmpty +> pats)
+> autoIndentAndNlnIfExpressionExceedsPageWidth (
sepNlnWhenWriteBeforeNewlineNotEmpty
+> pats
+> sepNlnWhenWriteBeforeNewlineNotEmpty
)
+> genSingleTextNode node.ClosingParen
|> genNode node

Expand Down

0 comments on commit cd04b16

Please sign in to comment.