mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
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
Some checks are pending
CI / ci (push) Waiting to run
This commit is contained in:
parent
d7caea32ab
commit
ecde81fc0c
2 changed files with 16 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue