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

Extra whitespace added to beginning or end of some lines #328

Closed
bdube opened this issue Oct 17, 2018 · 2 comments · Fixed by #336
Closed

Extra whitespace added to beginning or end of some lines #328

bdube opened this issue Oct 17, 2018 · 2 comments · Fixed by #336

Comments

@bdube
Copy link

bdube commented Oct 17, 2018

The formatting of this line
(fun () -> parser.ParseCommandLine [||] |> ignore)
is left unchanged, but fantomas 2.8.1 adds a single space to the end of the line.

Other reformatted sections also end up with a single space added to the end of some lines.

I'll try to describe this issue better by writing a failing test case. Also I see that 2.9.0 was just released, so I'll check that version as well.

Edit: I see the same behavior with 2.9.0. I'll work on a test case.

@bdube
Copy link
Author

bdube commented Oct 17, 2018

[<Test>]
let ``should not confuse me with an extra space at end of line v1``() =
    let codeSnippet = """(fun () -> parser.ParseCommandLine [||] |> ignore)"""

    formatSourceString false codeSnippet config
    |> should equal """(fun () -> parser.ParseCommandLine [||] |> ignore)
"""

[<Test>]
let ``should not confuse me with an extra space at end of line v2``() =
    let codeSnippet = """let ``should not extrude without positive distance`` () =
    let args = [| "-i"; "input.dxf"; "-o"; "output.pdf"; "--op"; "extrude"; |]
    (fun () -> parseCmdLine args |> ignore)
    |> should throw typeof<Argu.ArguParseException>"""

    formatSourceString false codeSnippet config
    |> should equal """let ``should not extrude without positive distance``() =
    let args = [| "-i"; "input.dxf"; "-o"; "output.pdf"; "--op"; "extrude" |]
    (fun () -> parseCmdLine args |> ignore)
    |> should throw typeof<Argu.ArguParseException>
"""

Note, the first test passes when testing with formatSourceString, but it's an actual example of a line that fantomas (2.8.1|2.9.0) adds an extra space to my code.

The second test fails and shows the extra space I am seeing with fantomas (2.8.1|2.9.0).

@bdube bdube changed the title Single space added to end of some lines Extra whitespace added to beginning or end of some lines Oct 18, 2018
@bdube
Copy link
Author

bdube commented Oct 18, 2018

In another project, I'm also getting extra leading whitespace with fantomas 2.9.0:

[<Test>]
let ``should not confuse me with extra spaces v1``() =
    let codeSnippet = """let errorHandler = ProcessExiter(colorizer = function ErrorCode.HelpText -> None | _ -> Some ConsoleColor.Red)"""
    formatSourceString false codeSnippet config
    |> should equal """let errorHandler =
    ProcessExiter(colorizer = function
                  | ErrorCode.HelpText -> None
                  | _ -> Some ConsoleColor.Red)
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant