fix(picker): pause input progress info for 60ms to prevent flickering when finder is too fast
Some checks are pending
CI / ci (push) Waiting to run

This commit is contained in:
Folke Lemaitre 2025-10-26 21:05:17 +01:00
parent d7caea32ab
commit ecde81fc0c
No known key found for this signature in database
GPG key ID: 9B52594D560070AB
2 changed files with 16 additions and 4 deletions

View file

@ -3,6 +3,7 @@
---@field totals string
---@field picker snacks.Picker
---@field filter snacks.picker.Filter
---@field paused? boolean
local M = {}
M.__index = M
@ -142,7 +143,7 @@ function M:update()
Snacks.util.wo(self.win.win, { statuscolumn = sc })
end
local line = {} ---@type snacks.picker.Highlight[]
if self.picker:is_active() then
if self.picker:is_active() and self.spinner ~= false then
line[#line + 1] = { Snacks.util.spinner(), "SnacksPickerSpinner" }
line[#line + 1] = { " " }
end
@ -171,6 +172,14 @@ function M:get()
return self.win:line()
end
function M:pause(ms)
self.paused = true
vim.defer_fn(function()
self.paused = false
self:update()
end, ms or 100)
end
---@param pattern? string
---@param search? string
function M:set(pattern, search)

View file

@ -744,11 +744,11 @@ function M:update(opts)
end
if self.shown then
if not self:is_active() then
if not self:is_active() or list_count > 3 then
self.list:unpause()
end
-- update list and input
if not self.list.paused then
if not self.input.paused then
self.input:update()
end
self.list:update(opts)
@ -819,7 +819,7 @@ function M:find(opts)
self:update_titles()
if self:count() > 0 then
-- pause rapid list updates to prevent flickering
self.list:pause(60)
self.list:pause(2000)
end
self.finder:run(self)
end
@ -834,6 +834,9 @@ function M:find(opts)
opts.on_done()
end
end
self.input:pause(60)
self:progress()
end
end