mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
fix: detect async context more robustly (#254)
This commit is contained in:
parent
476f70e1b0
commit
38f2a2207e
@ -21,7 +21,8 @@ local frecency = setmetatable({}, {
|
|||||||
return function(...)
|
return function(...)
|
||||||
if not instance() then
|
if not instance() then
|
||||||
rawset(self, "instance", require("frecency.klass").new())
|
rawset(self, "instance", require("frecency.klass").new())
|
||||||
instance():setup()
|
local is_async = key == "delete" or key == "validate_database" or key == "register"
|
||||||
|
instance():setup(is_async)
|
||||||
end
|
end
|
||||||
return instance()[key](instance(), ...)
|
return instance()[key](instance(), ...)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,8 +23,9 @@ Frecency.new = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---This is called when `:Telescope frecency` is called at the first time.
|
---This is called when `:Telescope frecency` is called at the first time.
|
||||||
|
---@param is_async boolean
|
||||||
---@return nil
|
---@return nil
|
||||||
function Frecency:setup()
|
function Frecency:setup(is_async)
|
||||||
---@async
|
---@async
|
||||||
local function init()
|
local function init()
|
||||||
timer.track "init() start"
|
timer.track "init() start"
|
||||||
@ -36,7 +37,6 @@ function Frecency:setup()
|
|||||||
timer.track "init() finish"
|
timer.track "init() finish"
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_async = not not coroutine.running()
|
|
||||||
if is_async then
|
if is_async then
|
||||||
init()
|
init()
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user