Skip to content

Commit

Permalink
Indented one step from the match/|. Fixes #1501 (#1517)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Mar 12, 2021
1 parent ec05c24 commit 511646c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 42 deletions.
52 changes: 26 additions & 26 deletions src/Fantomas.Tests/ComputationExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1609,25 +1609,25 @@ let rec loop () =
match msg with
| Handle (eventSource, command, reply) ->
let! stream = eventSource |> eventStore.GetStream
let newEvents =
stream
|> Result.map (
asEvents
>> behaviour command
>> enveloped eventSource
)
let! stream = eventSource |> eventStore.GetStream
let newEvents =
stream
|> Result.map (
asEvents
>> behaviour command
>> enveloped eventSource
)
let! result =
newEvents
|> function
| Ok events -> eventStore.Append events
| Error err -> async { return Error err}
let! result =
newEvents
|> function
| Ok events -> eventStore.Append events
| Error err -> async { return Error err}
do reply.Reply result
do reply.Reply result
return! loop ()
return! loop ()
}
"""

Expand Down Expand Up @@ -2199,11 +2199,11 @@ type ProjectController(checker: FSharpChecker) =
async {
match Environment.workspaceLoadDelay () with
| delay when delay > TimeSpan.Zero ->
do!
Async.Sleep(
Environment.workspaceLoadDelay().TotalMilliseconds
|> int
)
do!
Async.Sleep(
Environment.workspaceLoadDelay().TotalMilliseconds
|> int
)
| _ -> ()
return true
Expand Down Expand Up @@ -2237,11 +2237,11 @@ type ProjectController(checker: FSharpChecker) =
async {
match Environment.workspaceLoadDelay () with
| delay when delay > TimeSpan.Zero ->
do
NonAsync.Sleep(
Environment.workspaceLoadDelay().TotalMilliseconds
|> int
)
do
NonAsync.Sleep(
Environment.workspaceLoadDelay().TotalMilliseconds
|> int
)
| _ -> ()
return true
Expand Down
16 changes: 8 additions & 8 deletions src/Fantomas.Tests/IfThenElseTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,14 +1651,14 @@ let tryDecompile (ty: FSharpEntity) =
match ty.TryFullName with
| Some fullName -> return decompile ty.Assembly.SimpleName externalSym
| None ->
// might be abbreviated type (like string)
return!
(if ty.IsFSharpAbbreviation then
Some ty.AbbreviatedType
else
None)
|> tryGetTypeDef
|> tryGetSource
// might be abbreviated type (like string)
return!
(if ty.IsFSharpAbbreviation then
Some ty.AbbreviatedType
else
None)
|> tryGetTypeDef
|> tryGetSource
}
"""

Expand Down
27 changes: 25 additions & 2 deletions src/Fantomas.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ match x with
"""
match x with
| Some y ->
let z = 1
Some(y + z)
let z = 1
Some(y + z)
| None -> None
"""

Expand Down Expand Up @@ -1387,3 +1387,26 @@ match!
| "" -> x
| _ -> failwith ""
"""

[<Test>]
let ``indented one step from the match/|., 1501`` () =
formatSourceString
false
"""
match x with
| Some y ->
// meh
y
| None -> 42
"""
{ config with IndentSize = 2 }
|> prepend newline
|> should
equal
"""
match x with
| Some y ->
// meh
y
| None -> 42
"""
8 changes: 2 additions & 6 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4377,12 +4377,8 @@ and genClause astContext hasBar (Clause (p, e, eo) as ce) =
+> fun ctx -> leaveNodeTokenByName (arrowRange ctx) RARROW ctx

genTriviaBeforeClausePipe p.Range
+> ifElse
hasBar
(sepBar +> atCurrentColumnWithPrepend pat body
|> genTriviaFor SynMatchClause_Clause ce.Range)
(pat +> body
|> genTriviaFor SynMatchClause_Clause ce.Range)
+> (onlyIf hasBar sepBar +> pat +> body
|> genTriviaFor SynMatchClause_Clause ce.Range)

/// Each multiline member definition has a pre and post new line.
and genMemberDefnList astContext nodes =
Expand Down

0 comments on commit 511646c

Please sign in to comment.