From 58a5013f9757cde40169dafa020609758271d352 Mon Sep 17 00:00:00 2001 From: Giuseppe Lippolis Date: Sat, 28 Oct 2023 10:29:23 +0200 Subject: [PATCH] fix: When tagName is not Empty do not show XML Comment and auto close tag --- .../Completion/CompletionEngine.cs | 24 ++++++++++--------- tests/CompletionEngineTests/BasicTests.cs | 6 ++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CompletionEngine/Avalonia.Ide.CompletionEngine/Completion/CompletionEngine.cs b/CompletionEngine/Avalonia.Ide.CompletionEngine/Completion/CompletionEngine.cs index 0dadde4b..08ac8f5d 100644 --- a/CompletionEngine/Avalonia.Ide.CompletionEngine/Completion/CompletionEngine.cs +++ b/CompletionEngine/Avalonia.Ide.CompletionEngine/Completion/CompletionEngine.cs @@ -260,22 +260,24 @@ private static Dictionary GetNamespaceAliases(string xml) } else { - if (state.GetParentTagName(1) is string parentTag) + if (tagName.Length == 0) { - if (!state.IsInClosingTag) + if (state.GetParentTagName(1) is string parentTag) { - completions.Add(new Completion("/" + parentTag + ">", CompletionKind.Class, priority: 0)); - } - if (parentTag.IndexOf('.') == -1) - { - completions.Add(new Completion(parentTag, $"{parentTag}.", CompletionKind.Class, priority: 1) + if (!state.IsInClosingTag) + { + completions.Add(new Completion("/" + parentTag + ">", CompletionKind.Class, priority: 0)); + } + if (parentTag.IndexOf('.') == -1) { - TriggerCompletionAfterInsert = true, - }); + completions.Add(new Completion(parentTag, $"{parentTag}.", CompletionKind.Class, priority: 1) + { + TriggerCompletionAfterInsert = true, + }); + } } + completions.Add(new Completion("!--", "!---->", CompletionKind.Comment) { RecommendedCursorOffset = 3 }); } - completions.Add(new Completion("!--", "!---->", CompletionKind.Comment) { RecommendedCursorOffset = 3 }); - completions.AddRange(Helper.FilterTypes(tagName) .Where(kvp=>!kvp.Value.IsAbstract) .Select(kvp => diff --git a/tests/CompletionEngineTests/BasicTests.cs b/tests/CompletionEngineTests/BasicTests.cs index 5cc01b16..acbc9a9f 100644 --- a/tests/CompletionEngineTests/BasicTests.cs +++ b/tests/CompletionEngineTests/BasicTests.cs @@ -139,9 +139,9 @@ public void Completions_Should_Be_Sorted() { var compl = GetCompletionsFor("