diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2020-07-29 20:25:57 -0400 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2020-07-29 20:25:57 -0400 |
commit | 679869e6271ce00de20e109831b5e99d89a99b19 (patch) | |
tree | c72ae03ab509b3744024f9cdf489697a508364bf /core/keys.lua | |
parent | df1862134f65acc19551bd61b1de41a77d645a00 (diff) |
Fixed `keys.keychain` access if #keychain > 1.
When clearing key sequences, preserve the table, as the `__index` metatable IS
that table.
Diffstat (limited to 'core/keys.lua')
-rw-r--r-- | core/keys.lua | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/core/keys.lua b/core/keys.lua index 2b93730b..d805b4f1 100644 --- a/core/keys.lua +++ b/core/keys.lua @@ -162,10 +162,7 @@ M.keychain = setmetatable({}, { }) -- Clears the current key sequence. --- Note: clearing a table is often faster than re-creating one. -local function clear_key_sequence() - if #keychain == 1 then keychain[1] = nil else keychain = {} end -end +local function clear_key_seq() for i = 1, #keychain do keychain[i] = nil end end -- Return codes for `key_command()`. local INVALID, PROPAGATE, CHAIN, HALT = -1, 0, 1, 2 @@ -221,7 +218,7 @@ local function keypress(code, shift, control, alt, cmd, caps_lock) ui.statusbar_text = '' --if CURSES then ui.statusbar_text = string.format('"%s"', key_seq) end local in_chain = #keychain > 0 - if in_chain and key_seq == M.CLEAR then clear_key_sequence() return true end + if in_chain and key_seq == M.CLEAR then clear_key_seq() return true end keychain[#keychain + 1] = key_seq local status = PROPAGATE @@ -231,7 +228,7 @@ local function keypress(code, shift, control, alt, cmd, caps_lock) else status = key_command(M.mode) end - if status ~= CHAIN then clear_key_sequence() end + if status ~= CHAIN then clear_key_seq() end if status > PROPAGATE then return true end -- CHAIN or HALT if status == INVALID and in_chain then ui.statusbar_text = _L['Invalid sequence'] |