Improve how simple (number-indexed) Lua tables are printed

also might change sort order for associative tables in some edge cases
This commit is contained in:
YoshiRulz 2025-05-25 00:40:29 +10:00
parent b6bcd083a3
commit 631e5c37b4
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 6 additions and 1 deletions

View File

@ -69,7 +69,12 @@ namespace BizHawk.Client.EmuHawk
{
var entries = ((IEnumerator<KeyValuePair<object, object/*?*/>>) lti.GetEnumerator()).AsEnumerable()
.ToArray();
return string.Concat(entries.Select(static kvp => $"\"{kvp.Key}\": \"{kvp.Value}\"\n").Order());
Console.WriteLine(entries[0].Key.GetType().FullName);
return string.Concat(entries.All(static kvp => kvp.Key is long)
? entries.OrderBy(static kvp => (long) kvp.Key, Comparer<long>.Default)
.Select(static kvp => $"{kvp.Key}: \"{kvp.Value}\"\n")
: entries.OrderBy(static kvp => kvp.Key)
.Select(static kvp => $"\"{kvp.Key}\": \"{kvp.Value}\"\n"));
}
if (!Tools.Has<LuaConsole>())