From 8b1eb5a727920f91f78903925caff5da4575de0c Mon Sep 17 00:00:00 2001 From: dawe Date: Sat, 11 May 2024 18:20:47 +0200 Subject: [PATCH] don't offer the XML comment codefix on namespaces or anon modules (#1292) --- src/FsAutoComplete.Core/Commands.fs | 6 ++++-- test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/FsAutoComplete.Core/Commands.fs b/src/FsAutoComplete.Core/Commands.fs index 3a8b155d5..007fdb76c 100644 --- a/src/FsAutoComplete.Core/Commands.fs +++ b/src/FsAutoComplete.Core/Commands.fs @@ -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) -> diff --git a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs index 55b8c8f2a..08b8c3ed8 100644 --- a/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs +++ b/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs @@ -1852,7 +1852,18 @@ let private generateXmlDocumentationTests state = /// 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 ->