Fix code completion bug in Lua REPL

This commit is contained in:
Justine Tunney 2022-06-26 03:11:56 -07:00
parent 61257d48d4
commit 2f515ac5e3

View file

@ -116,8 +116,9 @@ void lua_readline_completions (const char *p, linenoiseCompletions *c) {
a = p;
b = strpbrk(a, ".:");
while (b) {
component = strndup(a, b - a);
found = false;
if (lua_istable(L, -1)) {
component = strndup(a, b - a);
lua_pushnil(L); // search key
while (lua_next(L, -2)) {
if (lua_type(L, -2) == LUA_TSTRING) {
@ -132,6 +133,7 @@ void lua_readline_completions (const char *p, linenoiseCompletions *c) {
lua_pop(L, 1); // pop value
}
free(component);
}
if (!found) {
lua_pop(L, 1); // pop table
return;