11--- @diagnostic disable-next-line : deprecated
22local uv = vim .uv or vim .loop
33
4- local _is_win = vim .fn .has (" win32" ) == 1 or vim .fn .has (" win64" ) == 1
4+ -- local _is_win = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
5+ local _is_win = false
56
67local M = {}
78
@@ -204,12 +205,15 @@ M.spawn = function(opts, fn_transform, fn_done)
204205 local function split_lines (data )
205206 -- io.stderr:write("[DEBUG] worker init")
206207 if not _G .fzf_lua_worker_init then
208+ -- TODO: we can pass serialize opts to first queue...
209+ local __FILE__ = assert (debug.getinfo (1 , " S" )).source :gsub (" ^@" , " " )
210+ package.path = (" %s/?.lua;" ):format (vim .fs .dirname (vim .fs .dirname (__FILE__ ))) .. package.path
211+ require (" fzf-lua.make_entry" )
212+ print (' e' )
213+ -- print(vim.inspect(package.loaders))
207214 _G .fzf_lua_worker_init = true
208- -- local __FILE__ = assert(debug.getinfo(1, "S")).source:gsub("^@", "")
209- -- package.path = ("%s/?.lua;"):format(vim.fs.dirname(vim.fs.dirname(__FILE__))) .. package.path
210- -- require("fzf-lua")
211- -- pcall(require, "fzf-lua.make_entry")
212215 end
216+ local trans = require (" fzf-lua.make_entry" ).file
213217 local ret = {}
214218 local start_idx = 1
215219 repeat
@@ -218,6 +222,7 @@ M.spawn = function(opts, fn_transform, fn_done)
218222 local cr = data :byte (nl_idx - 1 , nl_idx - 1 ) == 13 -- \r
219223 local line = data :sub (start_idx , nl_idx - (cr and 2 or 1 ))
220224 -- if trans then line = trans(line) end
225+ line = trans (line , {})
221226 if line then ret [# ret + 1 ] = line end
222227 start_idx = nl_idx + 1
223228 end
@@ -492,7 +497,7 @@ M.spawn_stdio = function(opts)
492497 local on_write = function (data , cb )
493498 if stdout then
494499 pipe_write (stdout , data , cb )
495- else
500+ elseif data then
496501 -- on success: rc=true, err=nil
497502 -- on failure: rc=nil, err="Broken pipe"
498503 -- cb with an err ends the process
0 commit comments