|
1 | 1 | ---@diagnostic disable-next-line: deprecated |
2 | 2 | local uv = vim.uv or vim.loop |
3 | 3 |
|
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 |
5 | 6 |
|
6 | 7 | local M = {} |
7 | 8 |
|
@@ -126,7 +127,7 @@ M.spawn = function(opts, fn_transform, fn_done) |
126 | 127 |
|
127 | 128 | ---@diagnostic disable-next-line: redefined-local |
128 | 129 | local finish = function(code, sig, from, pid) |
129 | | - os.execute("notify-send " .. write_cb_count) |
| 130 | + -- os.execute("notify-send " .. write_cb_count) |
130 | 131 | -- Uncomment to debug pipe closure timing issues (#1521) |
131 | 132 | -- output_pipe:close(function() print("closed o") end) |
132 | 133 | -- error_pipe:close(function() print("closed e") end) |
@@ -204,20 +205,25 @@ M.spawn = function(opts, fn_transform, fn_done) |
204 | 205 | local function split_lines(data) |
205 | 206 | -- io.stderr:write("[DEBUG] worker init") |
206 | 207 | 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 | + package.path = ("%s/?/init.lua;"):format(vim.fs.dirname(vim.fs.dirname(__FILE__))) .. |
| 212 | + package.path |
| 213 | + require("fzf-lua.make_entry") |
207 | 214 | _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") |
212 | 215 | end |
| 216 | + local trans = require("fzf-lua.make_entry").file |
213 | 217 | local ret = {} |
214 | 218 | local start_idx = 1 |
215 | 219 | repeat |
216 | 220 | local nl_idx = data:find(EOL_data or "\n", start_idx, true) |
217 | 221 | if nl_idx then |
218 | 222 | local cr = data:byte(nl_idx - 1, nl_idx - 1) == 13 -- \r |
219 | 223 | local line = data:sub(start_idx, nl_idx - (cr and 2 or 1)) |
220 | | - -- if trans then line = trans(line) end |
| 224 | + if trans then |
| 225 | + line = trans(line) |
| 226 | + end |
221 | 227 | if line then ret[#ret + 1] = line end |
222 | 228 | start_idx = nl_idx + 1 |
223 | 229 | end |
@@ -267,7 +273,7 @@ M.spawn = function(opts, fn_transform, fn_done) |
267 | 273 | else -- EOF signalled, we can close the pipe |
268 | 274 | output_pipe:close() |
269 | 275 | end |
270 | | - if #strbuf > 0 or output_pipe:is_closing() then |
| 276 | + if #strbuf > 100000 or output_pipe:is_closing() then |
271 | 277 | assert(coroutine.resume(co)) |
272 | 278 | end |
273 | 279 | end |
@@ -492,7 +498,7 @@ M.spawn_stdio = function(opts) |
492 | 498 | local on_write = function(data, cb) |
493 | 499 | if stdout then |
494 | 500 | pipe_write(stdout, data, cb) |
495 | | - else |
| 501 | + elseif data then |
496 | 502 | -- on success: rc=true, err=nil |
497 | 503 | -- on failure: rc=nil, err="Broken pipe" |
498 | 504 | -- cb with an err ends the process |
|
0 commit comments