Skip to content

Commit

Permalink
Fix #365 (#399)
Browse files Browse the repository at this point in the history
futureNlnCheck works correctly with empty string
  • Loading branch information
jindraivanek authored and nojaf committed Jan 23, 2019
1 parent f126455 commit 4a01781
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/Fantomas.Tests/LetBindingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,26 @@ let tomorrow =
let tomorrow =
DateTimeOffset(n.Year, n.Month, n.Day, 0, 0, 0, n.Offset)
.AddDays(1.)
"""

[<Test>]
let ``DotGet on newline after empty string should be indented far enough`` () =
formatSourceString false """
let x =
[| 1..2 |]
|> Array.mapi (fun _ _ ->
let num =
""
.PadLeft(9)
num)
""" config
|> prepend newline
|> should equal """
let x =
[| 1..2 |]
|> Array.mapi (fun _ _ ->
let num =
""
.PadLeft(9)
num)
"""
2 changes: 1 addition & 1 deletion src/Fantomas/Context.fs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ let internal futureNlnCheck f sep (ctx : Context) =
let withoutStringConst =
str.Replace("\\\\", System.String.Empty).Replace("\\\"", System.String.Empty).Split([|'"'|])
|> Seq.indexed |> Seq.filter (fun (i, _) -> i % 2 = 0) |> Seq.map snd |> String.concat System.String.Empty
let lines = withoutStringConst.Split([|Environment.NewLine|], StringSplitOptions.RemoveEmptyEntries)
let lines = withoutStringConst.Split([|Environment.NewLine|], StringSplitOptions.None)

(lines |> Seq.length) >= 2

Expand Down

0 comments on commit 4a01781

Please sign in to comment.