Skip to content

Commit

Permalink
Add atCurrentColumnIndent to match expression. Fixes fsprojects#1352.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Jan 8, 2021
1 parent d5f4d9f commit 158f118
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/Fantomas.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1128,3 +1128,23 @@ match foo with
getTriviaFromTokensThemSelves allTokens rest info
"""

[<Test>]
let ``multiline application call in match expression, 1352`` () =
formatSourceString
false
"""
match x (Map.tryFind somelongidentifier a + Option.defaultValue longidentifier) with
| _ -> ()
"""
config
|> prepend newline
|> should
equal
"""
match x (
Map.tryFind somelongidentifier a
+ Option.defaultValue longidentifier
) with
| _ -> ()
"""
2 changes: 1 addition & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ and genExpr astContext synExpr ctx =
| Match (e, cs) ->
atCurrentColumn (
!- "match "
+> genExpr astContext e
+> atCurrentColumnIndent (genExpr astContext e)
+> enterNodeTokenByName synExpr.Range WITH
// indent 'with' further if trivia was printed so that is appear after the match keyword.
+> ifElseCtx lastWriteEventIsNewline (rep 5 !- " ") sepNone
Expand Down

0 comments on commit 158f118

Please sign in to comment.