Skip to content

Commit 46e169a

Browse files
update serhelp methods display
1 parent 1e9a762 commit 46e169a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

Plugin/Commands/HelpSystem/HelpCommand.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ private static string GetEnumHelpPage()
406406
private static string GetMethodList()
407407
{
408408
var methods = MethodIndex.GetMethods();
409-
var maxMethodLen = methods.Max(m => m.Name.Length) + 7;
409+
const string retsPrefix = " [rets]";
410410

411411
Dictionary<string, List<Method>> methodsByCategory = new();
412412
foreach (var method in methods)
@@ -427,6 +427,10 @@ private static string GetMethodList()
427427

428428
foreach (var kvp in methodsByCategory.Reverse())
429429
{
430+
var descDistance = kvp.Value
431+
.Select(m => m.Name.Length + (m is ReturningMethod ? retsPrefix.Length : 0))
432+
.Max() + 1;
433+
430434
sb.AppendLine();
431435
sb.AppendLine($"--- {kvp.Key} methods ---");
432436
foreach (var method in kvp.Value)
@@ -437,18 +441,11 @@ private static string GetMethodList()
437441
name += " [rets]";
438442
}
439443

440-
if (maxMethodLen - name.Length > 0)
441-
{
442-
var desc = method.Description ?? $"Extracts information from {((IReferenceResolvingMethod)method).ReferenceType.Name} objects.";
443-
444-
var descFormatted = desc
445-
.Insert(0, new string(' ', maxMethodLen - name.Length));
446-
sb.AppendLine($"> {name} {descFormatted}");
447-
}
448-
else
449-
{
450-
sb.AppendLine($"> {name} {method.Description}");
451-
}
444+
var descDistanceString = new string(' ', descDistance - name.Length);
445+
var desc = method.Description
446+
?? $"Extracts information from {((IReferenceResolvingMethod)method).ReferenceType.Name} objects.";
447+
448+
sb.AppendLine($"> {name}{descDistanceString}~ {desc}");
452449
}
453450
}
454451

0 commit comments

Comments
 (0)