@@ -86,9 +86,9 @@ local function telescope_ui(opts)
8686 return {
8787 value = item ,
8888 display = function (entry )
89- return displayer (opts .format_fn (entry .value ):to_formatted_text ())
89+ return displayer (opts .format_fn (entry .value , opts . width ):to_formatted_text ())
9090 end ,
91- ordinal = opts .format_fn (item ):to_string (),
91+ ordinal = opts .format_fn (item , opts . width ):to_string (),
9292 }
9393 end
9494
@@ -189,7 +189,7 @@ local function fzf_ui(opts)
189189
190190 fzf_lua .fzf_exec (function (fzf_cb )
191191 for _ , item in ipairs (opts .items ) do
192- fzf_cb (opts .format_fn (item ):to_string ())
192+ fzf_cb (opts .format_fn (item , opts . width ):to_string ())
193193 end
194194 fzf_cb ()
195195 end , {
@@ -201,7 +201,7 @@ local function fzf_ui(opts)
201201 actions = actions_config ,
202202 fn_fzf_index = function (line )
203203 for i , item in ipairs (opts .items ) do
204- if opts .format_fn (item ):to_string () == line then
204+ if opts .format_fn (item , opts . width ):to_string () == line then
205205 return i
206206 end
207207 end
@@ -217,7 +217,7 @@ local function mini_pick_ui(opts)
217217
218218 --- @type MiniPickItem[]
219219 local items = vim .tbl_map (function (item )
220- return { text = opts .format_fn (item ):to_string (), item = item }
220+ return { text = opts .format_fn (item , opts . width ):to_string (), item = item }
221221 end , opts .items )
222222
223223 local mappings = {}
@@ -234,7 +234,7 @@ local function mini_pick_ui(opts)
234234 opts .items = new_items
235235 --- @type MiniPickItem[]
236236 items = vim .tbl_map (function (it )
237- return { text = opts .format_fn (it ):to_string (), item = it }
237+ return { text = opts .format_fn (it , opts . width ):to_string (), item = it }
238238 end , opts .items )
239239 mini_pick .set_picker_items (items )
240240 end
@@ -286,8 +286,15 @@ local function snacks_picker_ui(opts)
286286 finder = function ()
287287 return opts .items
288288 end ,
289- format = function (item )
290- return opts .format_fn (item ):to_formatted_text ()
289+ transform = function (item , ctx )
290+ -- Snacks requires item.text to be set to do matching
291+ if not item .text then
292+ local picker_item = opts .format_fn (item , ctx .picker .layout .width )
293+ item .text = picker_item :to_string ()
294+ end
295+ end ,
296+ format = function (item , snacks_picker )
297+ return opts .format_fn (item , snacks_picker .layout .width ):to_formatted_text ()
291298 end ,
292299 actions = {
293300 confirm = function (_picker , item )
@@ -392,11 +399,6 @@ function M.pick(opts)
392399 opts .width = config .ui .picker_width
393400 end
394401
395- local original_format_fn = opts .format_fn
396- opts .format_fn = function (item )
397- return original_format_fn (item , opts .width )
398- end
399-
400402 local title_str = type (opts .title ) == ' function' and opts .title () or opts .title --[[ @as string]]
401403 opts .title = build_title (title_str , opts .actions )
402404
0 commit comments