aboutsummaryrefslogtreecommitdiff
path: root/core/keys.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2011-02-06 16:59:23 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2011-02-06 16:59:23 -0500
commit086786f119430ee056a5780715ee4613bd781629 (patch)
tree32273ae970ab4d3f1a278954869b1b24e0698433 /core/keys.lua
parent6dd01c3740baf35b44e89df411d0ebbb51f9ad63 (diff)
downloadtextadept-086786f119430ee056a5780715ee4613bd781629.tar.gz
textadept-086786f119430ee056a5780715ee4613bd781629.zip
Clear keychain on key command error; core/keys.lua
Diffstat (limited to 'core/keys.lua')
-rw-r--r--core/keys.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/keys.lua b/core/keys.lua
index 29a06d6d..5a60b3ee 100644
--- a/core/keys.lua
+++ b/core/keys.lua
@@ -130,10 +130,11 @@ local ALT = 'a'..ADD
local string = _G.string
local string_char = string.char
local string_format = string.format
-local pcall = _G.pcall
+local xpcall = _G.xpcall
local next = _G.next
local type = _G.type
local unpack = _G.unpack
+local error = function(e) events.emit('error', e) end
---
-- Lookup table for key values higher than 255.
@@ -202,8 +203,8 @@ local function run_key_command(lexer, scope)
f, args = v[f], { v, unpack(key, 3) }
end
- if type(f) ~= 'function' then error(L('Unknown command:')..tostring(f)) end
- return f(unpack(args)) == false and PROPAGATE or HALT
+ local _, ret = xpcall(function() return f(unpack(args)) end, error)
+ return ret == false and PROPAGATE or HALT
end
-- Key command order for lexer and scope args passed to run_key_command().