Skip to content

Commit

Permalink
Always add new line between named module and first declaration. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Sep 17, 2020
1 parent b695df9 commit 4f84f92
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 4f84f92

Please sign in to comment.