fix lua autocomplete crash when a table contains number keys

This commit is contained in:
20dka authored and Lion Kortlepel committed 2022-11-23 09:34:51 +01:00
1 parent eaab5eaf30
commit 6a47521c7c
2 files changed
+9 -4

No files matched your search

+1
View File
@@ -298,6 +298,7 @@ void LuaAPI::MP::PrintRaw(sol::variadic_args Args) {
} }
int LuaAPI::PanicHandler(lua_State* State) { int LuaAPI::PanicHandler(lua_State* State) {
//FIXME: unsafe operation, can cause stack overflow
beammp_lua_error("PANIC: " + sol::stack::get<std::string>(State, 1)); beammp_lua_error("PANIC: " + sol::stack::get<std::string>(State, 1));
return 0; return 0;
} }
+8 -4
View File
@@ -253,11 +253,15 @@ std::vector<std::string> TLuaEngine::StateThreadData::GetStateTableKeys(const st
} else if (i == keys.size() - 1) { } else if (i == keys.size() - 1) {
if (obj.get_type() == sol::type::table) { if (obj.get_type() == sol::type::table) {
for (const auto& [key, value] : obj.as<sol::table>()) { for (const auto& [key, value] : obj.as<sol::table>()) {
std::string s = key.as<std::string>(); if (key.get_type() == sol::type::string) {
if (value.get_type() == sol::type::function) { std::string s = key.as<std::string>();
s += "(";
if (value.get_type() == sol::type::function) {
s += "(";
}
Result.push_back(s);
} }
Result.push_back(s);
} }
} else { } else {
Result = { obj.as<std::string>() }; Result = { obj.as<std::string>() };