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

Always add new line between named module and first declaration #1140

Merged
merged 1 commit into from
Sep 17, 2020
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
13 changes: 13 additions & 0 deletions src/Fantomas.Tests/ModuleTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,16 @@ module Test =
type t = T of bool
let foo = true
"""

[<Test>]
let ``always add new line between named module and first declaration, 1139`` () =
formatSourceString false """
module Input
let modules = [109024;137172;80445;80044]
""" config
|> prepend newline
|> should equal """
module Input

let modules = [ 109024; 137172; 80445; 80044 ]
"""
7 changes: 6 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ and genModuleOrNamespace astContext (ModuleOrNamespace (ats, px, ao, s, mds, isR
+> sepNln
else
sepNlnForEmptyNamespace node.Range +> sepNln
| Some _ -> sepNln
| Some mdl ->
let attrs =
getRangesFromAttributesFromModuleDeclaration mdl

sepNln
+> sepNlnConsideringTriviaContentBeforeWithAttributesFor (synModuleDeclToFsAstType mdl) mdl.Range attrs

let genTriviaForLongIdent (f: Context -> Context) =
match node with
Expand Down