Skip to content

Commit

Permalink
Merge branch 'main' into update_analyzers_0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
dawedawe committed Dec 20, 2023
2 parents 268f88e + 5dcd417 commit aa3238f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Fixed
* Unmatched '{' error when formatting the code. [#3017](https://github.com/fsprojects/fantomas/issues/3017)
* Comment lost after named pat pair. [#2953](https://github.com/fsprojects/fantomas/issues/2953)

## 6.3.0-alpha-004 - 2023-12-06

Expand Down
24 changes: 24 additions & 0 deletions src/Fantomas.Core.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2262,3 +2262,27 @@ match subcategory with
// Just treat as an unknown-to-LanguageService error.
-> false
"""

[<Test>]
let ``comment lost after named pat pair, 2953`` () =
formatSourceString
"""
match synExpr with
| SynExpr.App(
argExpr = SynExpr.Match _ // CCC
)
->
Some ident.idRange
| _ -> defaultTraverse synExpr
"""
config
|> prepend newline
|> should
equal
"""
match synExpr with
| SynExpr.App(
argExpr = SynExpr.Match _ // CCC
) -> Some ident.idRange
| _ -> defaultTraverse synExpr
"""
7 changes: 6 additions & 1 deletion src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2594,6 +2594,7 @@ let genPat (p: Pattern) =
+> genSingleTextNode node.Equals
+> sepSpace
+> genPat node.Pattern
|> genNode node

let pats =
expressionFitsOnRestOfLine
Expand All @@ -2604,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 aa3238f

Please sign in to comment.