mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-05 21:24:41 +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;
|
a = p;
|
||||||
b = strpbrk(a, ".:");
|
b = strpbrk(a, ".:");
|
||||||
while (b) {
|
while (b) {
|
||||||
component = strndup(a, b - a);
|
|
||||||
found = false;
|
found = false;
|
||||||
lua_pushnil(L); // search key
|
if (lua_istable(L, -1)) {
|
||||||
while (lua_next(L, -2)) {
|
component = strndup(a, b - a);
|
||||||
if (lua_type(L, -2) == LUA_TSTRING) {
|
lua_pushnil(L); // search key
|
||||||
name = lua_tostring(L, -2);
|
while (lua_next(L, -2)) {
|
||||||
if (!strcmp(name, component)) {
|
if (lua_type(L, -2) == LUA_TSTRING) {
|
||||||
lua_remove(L, -3); // remove table
|
name = lua_tostring(L, -2);
|
||||||
lua_remove(L, -2); // remove key
|
if (!strcmp(name, component)) {
|
||||||
found = true;
|
lua_remove(L, -3); // remove table
|
||||||
break;
|
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) {
|
if (!found) {
|
||||||
lua_pop(L, 1); // pop table
|
lua_pop(L, 1); // pop table
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue