Skip to content

Commit

Permalink
Fix for #483
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Sep 27, 2019
1 parent 3df63ec commit d03768f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/Fantomas.Tests/ControlStructureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,23 @@ elif bar then
| None -> printfn "%s" "meh"
else
()
"""

[<Test>]
let ``else keyword should be on separate line, #483`` () =
formatSourceString false """ if i.OpCode = OpCodes.Switch then
AccumulateSwitchTargets i targets
c
else
let branch = i.Operand :?> Cil.Instruction
c + (Option.nullable branch.Previous)
""" config
|> prepend newline
|> should equal """
if i.OpCode = OpCodes.Switch then
AccumulateSwitchTargets i targets
c
else
let branch = i.Operand :?> Cil.Instruction
c + (Option.nullable branch.Previous)
"""
2 changes: 1 addition & 1 deletion src/Fantomas/Context.fs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ let internal (+~) (ctx : Context -> Context) (str : string) x =
dump ctx
|> String.normalizeThenSplitNewLine
|> Array.tryLast
|> Option.map (fun (line:string) -> line.Trim().Length > 1)
|> Option.map (fun (line:string) -> not(System.String.IsNullOrWhiteSpace(line)))
|> Option.defaultValue false
let c = ctx x
if addNewline c then
Expand Down

0 comments on commit d03768f

Please sign in to comment.