From ea810cb89ba8127ed4151d0020e5eea28fbb8671 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 10 Jan 2025 23:12:20 +1000 Subject: [PATCH] Hide unavailable Lua libs from REPL autocomplete see #4167 --- src/BizHawk.Client.Common/lua/LuaDocumentation.cs | 5 ++++- src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs | 4 +++- src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.Common/lua/LuaDocumentation.cs b/src/BizHawk.Client.Common/lua/LuaDocumentation.cs index fb6d7dd6cd..a2ed3a5209 100644 --- a/src/BizHawk.Client.Common/lua/LuaDocumentation.cs +++ b/src/BizHawk.Client.Common/lua/LuaDocumentation.cs @@ -198,11 +198,14 @@ namespace BizHawk.Client.Common private readonly LuaMethodAttribute _luaAttributes; 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(false); _luaExampleAttribute = method.GetCustomAttribute(false); Method = method; + SuggestInREPL = suggestInREPL; IsDeprecated = method.GetCustomAttribute(false) != null; Library = library; diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 1e13fe4e10..91cc07d136 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -220,7 +220,9 @@ namespace BizHawk.Client.EmuHawk Emulator, 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) { diff --git a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs index db48685d09..1ffbe37ba5 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs @@ -47,7 +47,8 @@ namespace BizHawk.Client.EmuHawk name, type.GetCustomAttributes(typeof(DescriptionAttribute), false).Cast() .Select(descAttr => descAttr.Description).FirstOrDefault() ?? string.Empty, - method + method, + suggestInREPL: false ); Docs.Add(libFunc); }