commit 3198038224209c41932a305e2a2dee708d4e3ec8
parent 88ed9ffcd1c022811ebc8818e153fe94e4741671
Author: altermo <107814000+altermo@users.noreply.github.com>
Date: Tue, 7 Nov 2023 01:33:38 +0100
fix(lua): correct return value for on_key with no arguments (#25911)
Diffstat:
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
@@ -650,7 +650,7 @@ local on_key_cbs = {}
---if on_key() is called without arguments.
function vim.on_key(fn, ns_id)
if fn == nil and ns_id == nil then
- return #on_key_cbs
+ return vim.tbl_count(on_key_cbs)
end
vim.validate({
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
@@ -2438,6 +2438,12 @@ describe('lua stdlib', function()
end)
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]])
exec_lua [[