Hide unavailable Lua libs from REPL autocomplete

see #4167
This commit is contained in:
YoshiRulz 2025-01-10 23:12:20 +10:00
parent 7149609229
commit ea810cb89b
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 9 additions and 3 deletions

View File

@ -198,11 +198,14 @@ namespace BizHawk.Client.Common
private readonly LuaMethodAttribute _luaAttributes; private readonly LuaMethodAttribute _luaAttributes;
private readonly LuaMethodExampleAttribute _luaExampleAttribute; private readonly LuaMethodExampleAttribute _luaExampleAttribute;
public LibraryFunction(string library, string libraryDescription, MethodInfo method) public readonly bool SuggestInREPL;
public LibraryFunction(string library, string libraryDescription, MethodInfo method, bool suggestInREPL = true)
{ {
_luaAttributes = method.GetCustomAttribute<LuaMethodAttribute>(false); _luaAttributes = method.GetCustomAttribute<LuaMethodAttribute>(false);
_luaExampleAttribute = method.GetCustomAttribute<LuaMethodExampleAttribute>(false); _luaExampleAttribute = method.GetCustomAttribute<LuaMethodExampleAttribute>(false);
Method = method; Method = method;
SuggestInREPL = suggestInREPL;
IsDeprecated = method.GetCustomAttribute<LuaDeprecatedMethodAttribute>(false) != null; IsDeprecated = method.GetCustomAttribute<LuaDeprecatedMethodAttribute>(false) != null;
Library = library; Library = library;

View File

@ -220,7 +220,9 @@ namespace BizHawk.Client.EmuHawk
Emulator, Emulator,
Game); Game);
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray()); InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Where(static f => f.SuggestInREPL)
.Select(static f => $"{f.Library}.{f.Name}")
.ToArray());
foreach (var file in runningScripts) foreach (var file in runningScripts)
{ {

View File

@ -47,7 +47,8 @@ namespace BizHawk.Client.EmuHawk
name, name,
type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast<DescriptionAttribute>() type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast<DescriptionAttribute>()
.Select(descAttr => descAttr.Description).FirstOrDefault() ?? string.Empty, .Select(descAttr => descAttr.Description).FirstOrDefault() ?? string.Empty,
method method,
suggestInREPL: false
); );
Docs.Add(libFunc); Docs.Add(libFunc);
} }