From 673585ee997b40d2600eb86c3693d552e4f5d79f Mon Sep 17 00:00:00 2001 From: JINNOUCHI Yasushi Date: Tue, 20 Aug 2024 15:46:15 +0900 Subject: [PATCH] fix: delay calling vim.ui.select to avoid errors (#246) Fix #243 It occurs an error E5560 when UI to select `y/n` by the user in validating DB. This delays it until the next tick to avoid errors. --- lua/frecency/klass.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/frecency/klass.lua b/lua/frecency/klass.lua index 855555b..fdfc951 100644 --- a/lua/frecency/klass.lua +++ b/lua/frecency/klass.lua @@ -43,7 +43,7 @@ function Frecency:setup() init() else async.void(init)() - local ok, status = vim.wait(1000, function() + local ok, status = vim.wait(10000, function() return done end) if not ok then @@ -99,6 +99,9 @@ function Frecency:validate_database(force) remove_entries() return end + -- HACK: This is needed because the default implementaion of vim.ui.select() + -- uses vim.fn.* function and it makes E5560 error. + async.util.scheduler() vim.ui.select({ "y", "n" }, { prompt = self:message("remove %d entries from database?", #unlinked), ---@param item "y"|"n"