refactor(picker): on_move => on_change

This commit is contained in:
Folke Lemaitre 2025-01-14 11:50:25 +01:00
parent 6a523768cf
commit e390b7d874
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 4 additions and 4 deletions

View file

@ -74,7 +74,7 @@ local M = {}
---@field sources? snacks.picker.sources.Config|{}
---@field icons? snacks.picker.icons
---@field source? string
---@field on_moved? fun(picker:snacks.Picker, item:snacks.picker.Item)
---@field on_change? fun(picker:snacks.Picker, item:snacks.picker.Item) called when the cursor changes
---@field layouts? table<string, snacks.picker.Layout>
local defaults = {
prompt = "",

View file

@ -425,7 +425,7 @@ M.picker_format = {
M.picker_layouts = {
finder = "meta_layouts",
format = "text",
on_moved = function(picker, item)
on_change = function(picker, item)
vim.schedule(function()
picker:set_layout(item.text)
end)

View file

@ -244,8 +244,8 @@ function M:debug(name, start)
end
function M:show_preview()
if self.opts.on_moved then
self.opts.on_moved(self, self:current())
if self.opts.on_change then
self.opts.on_change(self, self:current())
end
if not self.preview.win:valid() then
return