diff --git a/lua/snacks/picker/core/input.lua b/lua/snacks/picker/core/input.lua index 3eade7af..fe1b62f6 100644 --- a/lua/snacks/picker/core/input.lua +++ b/lua/snacks/picker/core/input.lua @@ -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) diff --git a/lua/snacks/picker/core/picker.lua b/lua/snacks/picker/core/picker.lua index 41945ba4..761f484d 100644 --- a/lua/snacks/picker/core/picker.lua +++ b/lua/snacks/picker/core/picker.lua @@ -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