Skip to content
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

Detect multiline clause by UnIndentBy event. #1722

Merged
merged 1 commit into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/Fantomas.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1858,3 +1858,30 @@ match x with
with e -> printfn "failure %A" e)
--*-- bar
"""

[<Test>]
let ``match with single line last clause followed by line comment and infix operator, 1721 `` () =
formatSourceString
false
"""
let select p =
match p with
| voo _ -> "v_"
| dd -> "dd_"
| q -> "q_" // comment
|> List.singleton
|> instruction "s"
"""
{ config with IndentSize = 2 }
|> prepend newline
|> should
equal
"""
let select p =
match p with
| voo _ -> "v_"
| dd -> "dd_"
| q -> "q_" // comment
|> List.singleton
|> instruction "s"
"""
4 changes: 2 additions & 2 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2695,8 +2695,8 @@ and genMultilineInfixExpr astContext e1 operatorText operatorExpr e2 =
|> Seq.tryHead
|> fun e ->
match e with
| Some (Write _) -> true
| _ -> false
| Some (UnIndentBy _) -> false
| _ -> true

if lastClauseIsSingleLine then
ctxAfterMatch
Expand Down