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

Indented one step from the match/|. #1517

Merged
merged 1 commit into from
Mar 12, 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
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