Skip to content

Commit

Permalink
Fix for fsprojects#505
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Oct 12, 2019
1 parent 906b81c commit e77e006
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/Fantomas.Tests/ModuleTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,21 @@ type T() =
type T() =
interface IDisposable with
override x.Dispose() = ()
"""

[<Test>]
let ``attribute on module after namespace`` () =
formatSourceString false """namespace SomeNamespace
[<AutoOpen>]
module Types =
let a = 5
""" config
|> prepend newline
|> should equal """
namespace SomeNamespace
[<AutoOpen>]
module Types =
let a = 5
"""
3 changes: 2 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ and genModuleOrNamespace astContext (ModuleOrNamespace(ats, px, ao, s, mds, isRe
match firstDecl with
| None -> rep 2 sepNln
| Some mdl ->
sepNlnConsideringTriviaContentBefore mdl.Range +> sepNln
let attrRanges = getRangesFromAttributesFromModuleDeclaration mdl
sepNlnConsideringTriviaContentBeforeWithAttributes mdl.Range attrRanges +> sepNln

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

0 comments on commit e77e006

Please sign in to comment.