Skip to content

Commit

Permalink
fix: delay calling vim.ui.select to avoid errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
delphinus committed Aug 20, 2024
1 parent 9d4d8d2 commit 18eeda2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lua/frecency/klass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,21 @@ function Frecency:validate_database(force)
remove_entries()
return
end
vim.ui.select({ "y", "n" }, {
prompt = self:message("remove %d entries from database?", #unlinked),
---@param item "y"|"n"
---@return string
format_item = function(item)
return item == "y" and "Yes. Remove them." or "No. Do nothing."
end,
}, function(item)
if item == "y" then
remove_entries()
else
self:notify "validation aborted"
end
vim.schedule(function()
vim.ui.select({ "y", "n" }, {
prompt = self:message("remove %d entries from database?", #unlinked),
---@param item "y"|"n"
---@return string
format_item = function(item)
return item == "y" and "Yes. Remove them." or "No. Do nothing."
end,
}, function(item)
if item == "y" then
remove_entries()
else
self:notify "validation aborted"
end
end)
end)
end

Expand Down

0 comments on commit 18eeda2

Please sign in to comment.