Skip to content

Commit

Permalink
don't offer the XML comment codefix on namespaces or anon modules (#1292
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dawedawe authored May 11, 2024
1 parent d9bc747 commit 8b1eb5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,8 +1361,10 @@ type Commands() =

member _.VisitModuleOrNamespace(_, synModuleOrNamespace) =
match synModuleOrNamespace with
| SynModuleOrNamespace(attribs = attributes; longId = longId; xmlDoc = xmlDoc) when
longIdentContainsPos longId pos && xmlDoc.IsEmpty
| SynModuleOrNamespace(attribs = attributes; longId = longId; xmlDoc = xmlDoc; kind = kind) when
kind = SynModuleOrNamespaceKind.NamedModule
&& longIdentContainsPos longId pos
&& xmlDoc.IsEmpty
->
Some(false, tryGetFirstAttributeLine attributes)
| SynModuleOrNamespace(decls = decls) ->
Expand Down
13 changes: 12 additions & 1 deletion test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,18 @@ let private generateXmlDocumentationTests state =
/// <summary></summary>
module MyNestedModule =
let x = 3
""" ])
"""

testCaseAsync "not applicable for namespace"
<| CodeFix.checkNotApplicable
server
"""
namespace N$0
module MyNestedModule =
let x = 3
"""
Diagnostics.acceptAll
selectCodeFix ])

let private addMissingXmlDocumentationTests state =
serverTestList (nameof AddMissingXmlDocumentation) state defaultConfigDto None (fun server ->
Expand Down

0 comments on commit 8b1eb5a

Please sign in to comment.