Fix xml tooltips processing to ignore excessive whitespaces

This commit is contained in:
Wojtek Figat
2024-05-22 23:10:05 +02:00
parent c23f2b61cc
commit eb07fd7b9a

View File

@@ -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<string, string> GetXmlDocs(Assembly assembly)
{
if (!_xmlCache.TryGetValue(assembly, out var result))