fix invalid command handling

This commit is contained in:
Xinhao Yuan 2020-04-23 23:15:32 -04:00
parent 00e3e0aba5
commit 72835899ee
1 changed files with 26 additions and 19 deletions

View File

@ -585,16 +585,20 @@ function module.create(data)
[" "] = "-", [" "] = "-",
} }
-- 3 for taking the arg string and an open area
-- 2 for taking an open area
-- 1 for taking nothing
-- 0 for args
local ch_info = { local ch_info = {
["h"] = 2, ["H"] = 2, ["h"] = 3, ["H"] = 3,
["v"] = 2, ["V"] = 2, ["v"] = 3, ["V"] = 3,
["w"] = 2, ["W"] = 2, ["w"] = 3, ["W"] = 3,
["d"] = 2, ["D"] = 2, ["d"] = 3, ["D"] = 3,
["s"] = 2, ["S"] = 2, ["s"] = 3, ["S"] = 3,
["t"] = 2, ["T"] = 2, ["t"] = 3, ["T"] = 3,
["-"] = 1, ["-"] = 2,
["/"] = 2,
["."] = 1, ["."] = 1,
["/"] = 1,
[";"] = 1, [";"] = 1,
["0"] = 0, ["1"] = 0, ["2"] = 0, ["3"] = 0, ["4"] = 0, ["0"] = 0, ["1"] = 0, ["2"] = 0, ["3"] = 0, ["4"] = 0,
["5"] = 0, ["6"] = 0, ["7"] = 0, ["8"] = 0, ["9"] = 0, ["5"] = 0, ["6"] = 0, ["7"] = 0, ["8"] = 0, ["9"] = 0,
@ -608,20 +612,23 @@ function module.create(data)
local t = ch_info[key] local t = ch_info[key]
if t == nil then if t == nil then
return nil return nil
elseif t == 2 then elseif t == 3 then
if pending_op ~= nil then
handle_op(pending_op)
pending_op = key
elseif arg_str == "" then
pending_op = key
else
handle_op(key)
end
elseif t == 1 then
if pending_op ~= nil then if pending_op ~= nil then
handle_op(pending_op) handle_op(pending_op)
pending_op = nil pending_op = nil
end end
if #open_areas == 0 then return nil end
if arg_str == "" then
pending_op = key
else
handle_op(key)
end
elseif t == 2 or t == 1 then
if pending_op ~= nil then
handle_op(pending_op)
pending_op = nil
end
if #open_areas == 0 and t == 2 then return nil end
handle_op(key) handle_op(key)
elseif t == 0 then elseif t == 0 then
arg_str = arg_str .. key arg_str = arg_str .. key
@ -831,7 +838,7 @@ function module.create(data)
current_info = current_info .. ret current_info = current_info .. ret
current_cmd = current_cmd .. ret current_cmd = current_cmd .. ret
else else
discard_history() pop_history()
end end
if #open_areas == 0 then if #open_areas == 0 then