From eb07fd7b9a63e3f50176e03b7c2a80f4d07e78de Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 22 May 2024 23:10:05 +0200 Subject: [PATCH] Fix xml tooltips processing to ignore excessive whitespaces --- .../SourceCodeEditing/CodeDocsModule.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Modules/SourceCodeEditing/CodeDocsModule.cs b/Source/Editor/Modules/SourceCodeEditing/CodeDocsModule.cs index 02ca7be20..610368a82 100644 --- a/Source/Editor/Modules/SourceCodeEditing/CodeDocsModule.cs +++ b/Source/Editor/Modules/SourceCodeEditing/CodeDocsModule.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Text.RegularExpressions; using System.Xml; using FlaxEditor.Scripting; @@ -65,7 +66,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing { var key = "T:" + GetXmlKey(type.Type.FullName); if (xml.TryGetValue(key, out var xmlDoc)) - text += '\n' + xmlDoc; + text += '\n' + FilterWhitespaces(xmlDoc); } } @@ -262,6 +263,27 @@ namespace FlaxEditor.Modules.SourceCodeEditing return Regex.Replace(typeFullNameString, @"\[.*\]", string.Empty).Replace('+', '.'); } + private static string FilterWhitespaces(string str) + { + if (str.Contains(" ", StringComparison.Ordinal)) + { + var sb = new StringBuilder(); + var prev = str[0]; + sb.Append(prev); + for (int i = 1; i < str.Length; i++) + { + var c = str[i]; + if (prev != ' ' || c != ' ') + { + sb.Append(c); + } + prev = c; + } + str = sb.ToString(); + } + return str; + } + private Dictionary GetXmlDocs(Assembly assembly) { if (!_xmlCache.TryGetValue(assembly, out var result))