Skip to content

Commit 3e815df

Browse files
authored
Allow passing nil as name to hs.pasteboard.callbackWhenChanged (#3616)
The issue was that calling `hs.pasteboard.callbackWhenChanged(nil, 1, function() end)` raised "callback must be a function". This is because ipairs stops iterating the varargs table on the first nil element, so the for-loop body is not executed.
1 parent 8956fc3 commit 3e815df

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

extensions/pasteboard/pasteboard.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ end
8888
--- ~~~
8989
module.callbackWhenChanged = function(...)
9090
local name, timeout, callback = nil, 2.0, nil
91-
for _, v in ipairs({...}) do
91+
local args = {...}
92+
for i = 1, #args do
93+
local v = args[i]
9294
if type(v) == "number" then
9395
timeout = v
9496
elseif type(v) == "nil" or type(v) == "string" then

0 commit comments

Comments
 (0)