fix(lua): correct return value for on_key with no arguments

(cherry picked from commit 3edc8417f0)
This commit is contained in:
altermo
2023-11-06 10:27:57 +01:00
committed by github-actions[bot]
parent 412225c02a
commit 1413f3a971
2 changed files with 7 additions and 1 deletions

View File

@@ -544,7 +544,7 @@ local on_key_cbs = {}
---@note {fn} will receive the keys after mappings have been evaluated ---@note {fn} will receive the keys after mappings have been evaluated
function vim.on_key(fn, ns_id) function vim.on_key(fn, ns_id)
if fn == nil and ns_id == nil then if fn == nil and ns_id == nil then
return #on_key_cbs return vim.tbl_count(on_key_cbs)
end end
vim.validate({ vim.validate({

View File

@@ -2339,6 +2339,12 @@ describe('lua stdlib', function()
end) end)
it('allows removing on_key listeners', function() it('allows removing on_key listeners', function()
-- Create some unused namespaces
meths.create_namespace('unused1')
meths.create_namespace('unused2')
meths.create_namespace('unused3')
meths.create_namespace('unused4')
insert([[hello world]]) insert([[hello world]])
exec_lua [[ exec_lua [[