Skip to content

Commit

Permalink
Allow passing nil as name to hs.pasteboard.callbackWhenChanged (#3616)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Perlence authored Aug 5, 2024
1 parent 8956fc3 commit 3e815df
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion extensions/pasteboard/pasteboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ end
--- ~~~
module.callbackWhenChanged = function(...)
local name, timeout, callback = nil, 2.0, nil
for _, v in ipairs({...}) do
local args = {...}
for i = 1, #args do
local v = args[i]
if type(v) == "number" then
timeout = v
elseif type(v) == "nil" or type(v) == "string" then
Expand Down

0 comments on commit 3e815df

Please sign in to comment.