···2828 return
2929 end
30303131- local Picker = require("artio.picker")
3232- local current = Picker.active_picker
3333- if not current or not current.closed then
3434- return
3535- end
3636-3737- vim.schedule(function()
3838- vim.defer_fn(builtins[fname], 10)
3939- vim.wait(1000, function()
4040- return coroutine.status(current.co) == "dead"
4141- end)
4242- end)
3131+ artio.schedule(builtins[fname])
4332 end,
4433 }, props)
4534 )
+23-3
lua/artio/init.lua
···132132 "force",
133133 {
134134 on_close = function(_, idx)
135135- return on_choice(items[idx], idx)
135135+ artio.schedule(function()
136136+ on_choice(items[idx], idx)
137137+ end)
136138 end,
137139 on_quit = function()
138138- return on_choice(nil, nil)
140140+ artio.schedule(function()
141141+ on_choice(nil, nil)
142142+ end)
139143 end,
140144 },
141145 opts or {}, -- opts.prompt, opts.format_item
···160164 return Picker:new(...):open()
161165end
162166167167+---@param f fun(): any
168168+artio.schedule = function(f)
169169+ local Picker = require("artio.picker")
170170+ local current = Picker.active_picker
171171+ if not current or not current.closed then
172172+ return
173173+ end
174174+175175+ vim.schedule(function()
176176+ vim.defer_fn(f, 10)
177177+ vim.wait(1000, function()
178178+ return coroutine.status(current.co) == "dead"
179179+ end)
180180+ end)
181181+end
182182+163183---@param fn artio.Picker.action
164184---@param scheduled_fn? artio.Picker.action
165185artio.wrap = function(fn, scheduled_fn)
···180200 if scheduled_fn == nil then
181201 return
182202 end
183183- vim.schedule(function()
203203+ artio.schedule(function()
184204 pcall(scheduled_fn, current)
185205 end)
186206 end