summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--3rdparty/linenoise-ng/src/linenoise.cpp2
-rw-r--r--plugins/console/init.lua17
2 files changed, 7 insertions, 12 deletions
diff --git a/3rdparty/linenoise-ng/src/linenoise.cpp b/3rdparty/linenoise-ng/src/linenoise.cpp
index 38ef90bd63b..678a6bba78b 100644
--- a/3rdparty/linenoise-ng/src/linenoise.cpp
+++ b/3rdparty/linenoise-ng/src/linenoise.cpp
@@ -1883,7 +1883,7 @@ static int cleanupCtrl(int c) {
}
// break characters that may precede items to be completed
-static const char breakChars[] = " =+-/\\*?\"'`&<>;|@{([])}";
+static const char breakChars[] = " =+-/\\*?\"'`&<>;|@{}";
// maximum number of completions to display without asking
static const size_t completionCountCutoff = 100;
diff --git a/plugins/console/init.lua b/plugins/console/init.lua
index 3034b7c2cab..0b6cf595c9c 100644
--- a/plugins/console/init.lua
+++ b/plugins/console/init.lua
@@ -33,30 +33,26 @@ function console.startplugin()
scr = scr .. "return ln.linenoise('\x1b[1;36m[MAME]\x1b[0m> ')"
local function get_completions(str)
- local function is_pair_iterable(t)
- local mt = getmetatable(t)
- return type(t) == 'table' or (mt and mt.__pairs)
- end
local comps = ","
- local table = str:match("([(]?[%w.:()]-)[:.]?[%w_]*$")
+ local table = str:match("([(]?[%w.:()]-)[:.][%w_]*$")
local rest, last = str:match("(.-[:.]?)([%w_]*)$")
local err
- if table == "" then
+ if table == "" or not table then
table = "_G"
end
err, tablef = pcall(load("return " .. table))
if (not err) or (not tablef) then
return comps
end
- if is_pair_iterable(tablef) then
+ if type(tablef) == 'table' then
for k, v in pairs(tablef) do
if k:match("^" .. last) then
comps = comps .. "," .. rest .. k
end
end
end
- local tablef = getmetatable(tablef)
- if is_pair_iterable(tablef) then
+ if type(tablef) == "userdata" then
+ local tablef = getmetatable(tablef)
for k, v in pairs(tablef) do
if k:match("^" .. last) then
comps = comps .. "," .. rest .. k
@@ -74,6 +70,7 @@ function console.startplugin()
return
elseif started then
local cmd = conth.result
+ preload = false
local func, err = load(cmd)
if not func then
if err:match("<eof>") then
@@ -82,10 +79,8 @@ function console.startplugin()
preload = true
else
print("error: ", err)
- preload = false
end
else
- preload = false
local status
status, err = pcall(func)
if not status then