mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
Fix code completion bug in Lua REPL
This commit is contained in:
parent
61257d48d4
commit
2f515ac5e3
1 changed files with 14 additions and 12 deletions
26
third_party/lua/lrepl.c
vendored
26
third_party/lua/lrepl.c
vendored
|
@ -116,22 +116,24 @@ void lua_readline_completions (const char *p, linenoiseCompletions *c) {
|
|||
a = p;
|
||||
b = strpbrk(a, ".:");
|
||||
while (b) {
|
||||
component = strndup(a, b - a);
|
||||
found = false;
|
||||
lua_pushnil(L); // search key
|
||||
while (lua_next(L, -2)) {
|
||||
if (lua_type(L, -2) == LUA_TSTRING) {
|
||||
name = lua_tostring(L, -2);
|
||||
if (!strcmp(name, component)) {
|
||||
lua_remove(L, -3); // remove table
|
||||
lua_remove(L, -2); // remove key
|
||||
found = true;
|
||||
break;
|
||||
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) {
|
||||
name = lua_tostring(L, -2);
|
||||
if (!strcmp(name, component)) {
|
||||
lua_remove(L, -3); // remove table
|
||||
lua_remove(L, -2); // remove key
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
lua_pop(L, 1); // pop value
|
||||
}
|
||||
lua_pop(L, 1); // pop value
|
||||
free(component);
|
||||
}
|
||||
free(component);
|
||||
if (!found) {
|
||||
lua_pop(L, 1); // pop table
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue