@@ -127,24 +127,28 @@ end
127127function M .pipe_wrap_fn (fn , fzf_field_index , debug )
128128 fzf_field_index = fzf_field_index or " {+}"
129129
130- local receiving_function = function (pipe_path , ...)
130+ --- @param ctx fzf-lua.rpc.Ctx
131+ local receiving_function = function (ctx )
131132 local pipe = assert (uv .new_pipe (false ))
132- local args = { ... }
133+ local pipe_path = ctx . pipe_path
133134 -- unescape double backslashes on windows
134- if utils .__IS_WINDOWS and type (args [ 1 ] ) == " table" then
135- args [ 1 ] = vim .tbl_map (function (x )
135+ if utils .__IS_WINDOWS and type (ctx . selection ) == " table" then
136+ ctx . selection = vim .tbl_map (function (x )
136137 return libuv .unescape_fzf (x , vim .g .fzf_lua_fzf_version )
137- end , args [ 1 ] )
138+ end , ctx . selection )
138139 end
139- utils .get_info ().selected = args [1 ] and args [1 ][1 ] or nil
140+ -- for skim compatibility
141+ local preview_lines = tonumber (ctx .env .FZF_PREVIEW_LINES or ctx .env .LINES )
142+ local preview_cols = tonumber (ctx .env .FZF_PREVIEW_COLUMNS or ctx .env .COLUMNS )
143+ utils .get_info ().selected = (ctx .selection or {})[1 ]
140144 uv .pipe_connect (pipe , pipe_path , function (err )
141145 if err then
142146 --- @diagnostic disable-next-line : undefined-field
143147 err = uv .translate_sys_error (uv .errno [err ])
144148 utils .warn (string.format (" pipe_connect(%s) failed with error: %s" , pipe_path , err ))
145149 else
146150 vim .schedule (function ()
147- fn (pipe , unpack ( args ) )
151+ fn (pipe , ctx . selection , preview_lines , preview_cols , ctx )
148152 end )
149153 end
150154 end )
@@ -295,15 +299,15 @@ M.stringify = function(contents, opts, fzf_field_index)
295299 end
296300
297301 local cmd , id = M .pipe_wrap_fn (function (pipe , ...)
298- local args = { ... }
302+ local args , n = { ... }, select ( " # " , ... )
299303 -- Contents could be dependent or args, e.g. live_grep which
300304 -- generates a different command based on the typed query
301305 -- redefine local contents to prevent override on function call
302306 --- @type fzf-lua.content , table ?
303307 --- @diagnostic disable-next-line : redefined-local , assign-type-mismatch
304308 local contents , env = (function ()
305- local ret = opts .is_live and type (contents ) == " function" and contents (unpack (args ), opts )
306- or opts .__stringify_cmd and contents (unpack (args ))
309+ local ret = ( opts .is_live and type (contents ) == " function" and contents (unpack (args ), opts ) )
310+ or ( opts .__stringify_cmd and type ( contents ) == " function " and contents (unpack (args , 1 , n ) ))
307311 or contents
308312 if opts .__stringify_cmd and type (ret ) == " table" then
309313 return ret .cmd , (ret .env or opts .env )
@@ -428,7 +432,7 @@ M.stringify = function(contents, opts, fzf_field_index)
428432 vim .tbl_map (function (x ) on_write_nl (x ) end , contents )
429433 on_finish ()
430434 elseif type (contents ) == " function" then
431- contents (on_write_nl , on_write , unpack (args ))
435+ contents (on_write_nl , on_write , unpack (args , 1 , n ))
432436 end
433437 end , debug.traceback )
434438 if not ok and err then
@@ -442,9 +446,9 @@ M.stringify = function(contents, opts, fzf_field_index)
442446end
443447
444448--- @alias fzf-lua.shell.cmdSpec string |{ cmd : string | string[] , env : table ? }?
445- --- @alias fzf-lua.shell.cmd fun ( items : string[] , fzf_lines : integer , fzf_columns : integer ): fzf-lua.shell.cmdSpec
446- --- @alias fzf-lua.shell.data fun ( items : string[] , fzf_lines : integer , fzf_columns : integer ): fzf-lua.content ?
447- --- @alias fzf-lua.shell.data2 fun ( items : string[] , opts : fzf-lua.config.Resolved |{}): fzf-lua.content ?
449+ --- @alias fzf-lua.shell.cmd fun ( items : string[] , fzf_lines : integer , fzf_columns : integer , ctx ?: fzf-lua.rpc.Ctx ): fzf-lua.shell.cmdSpec
450+ --- @alias fzf-lua.shell.data fun ( items : string[] , fzf_lines : integer , fzf_columns : integer , ctx ?: fzf-lua.rpc.Ctx ): fzf-lua.content ?
451+ --- @alias fzf-lua.shell.data2 fun ( items : string[] , opts : fzf-lua.config.Resolved |{}, ctx ?: fzf-lua.rpc.Ctx ): fzf-lua.content ?
448452
449453--- @param fn fzf-lua.shell.cmd
450454--- @param opts table
0 commit comments