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 newline between attribute and function #611

Closed
martinbryant opened this issue Dec 27, 2019 · 3 comments · Fixed by #620
Closed

Extra newline between attribute and function #611

martinbryant opened this issue Dec 27, 2019 · 3 comments · Fixed by #620

Comments

@martinbryant
Copy link

Issue created from fantomas-ui

Using the CLI and the online tool both have the issue

Actual behaviour

v3.1.0 - Does not remove the extra whitespace in a file

Expected behaviour

v2.9.2 - The extra whitespace is removed

Steps to replicate

  • Click here

  • Change version to 2.9.2 and see the whitespace removed

Code

open System
open Library

[<EntryPoint>]





let main argv =
    printfn "Nice command-line arguments! Here's what JSON.NET has to say about them:" argv
    |> Array.map getJsonNetJson |> Array.iter (printfn "%s") 
    0 // return an integer exit code

Result

open System
open Library

[<EntryPoint>]






let main argv =
    printfn
        "Nice command-line arguments! Here's what JSON.NET has to say about them:"
        argv
    |> Array.map getJsonNetJson
    |> Array.iter(printfn "%s")
    0 // return an integer exit code

Options

Fantomas 3.1.0

Name Value
IndentOnTryWith false
IndentSpaceNum 4
KeepNewlineAfter false
MaxIfThenElseShortWidth 40
PageWidth 120
ReorderOpenDeclaration false
SemicolonAtEndOfLine false
SpaceAfterComma false
SpaceAfterSemicolon false
SpaceAroundDelimiter false
SpaceBeforeArgument false
SpaceBeforeColon false
StrictMode false
@nojaf
Copy link
Contributor

nojaf commented Dec 27, 2019

Hi @martinbryant, thanks for reporting these issues. I'm sorry to see that you had a bit of a rough start with Fantomas.

Regarding this issue, do you mean the blank lines when you say "extra whitespace"?
If so then this is by design actually. We preserve newlines from the original source code.

By that logic, the bug I see here is that an extra newline was added after formatting the code.

@martinbryant
Copy link
Author

martinbryant commented Dec 27, 2019

Ah @nojaf no problem. Been quite a learning experience to be fair.

Yeah I would have thought that the extra whitespace would be removed as it was in v2.9.2. Any formatters I have previously used(Prettier, elm-format) would remove any extra whitespace to provide a consistent experience.

Appreciate that the behaviour would change between versions though. Any reason why the preserveEOL flag was removed though? The behaviour was great before and when using the flag, no extra line is added

@nojaf
Copy link
Contributor

nojaf commented Jan 3, 2020

preserveEOL introduced a lot of problems and just didn't work in certain settings (f.ex indentSpaceNum = 2).
It became unmaintainable, to be honest.

I understand that the current behaviour isn't really what you expect coming from other formatters.
However, the most feedback I received about preserving the newlines from the original source code has be genuine positive.

Could you maybe create a new issue to discuss the removal of newlines? Maybe we can consider a setting to set a limit to the number of newlines.

I would like to use this issue to solve the problem that a new newline is introduced after formatting.

@nojaf nojaf changed the title Extra whitespace not removed Extra newline between attribute and function Jan 3, 2020
@nojaf nojaf closed this as completed in #620 Jan 6, 2020
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.

2 participants