summaryrefslogtreecommitdiff
path: root/lua/telescope/_.lua
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2021-12-05 08:29:03 +0100
committerGitHub <noreply@github.com>2021-12-05 08:29:03 +0100
commit1131e5f9e13f34f486e3eb66ca32ba8e1b714c96 (patch)
treef4c38c6589326b4909ee982f5322b327ec6aa13c /lua/telescope/_.lua
parent16b0188cf5ad4658d264a9f6a80a32af75e9bae4 (diff)
chore: better uv.spawn error handling and windows git spawn bugfix (#1498)
Diffstat (limited to 'lua/telescope/_.lua')
-rw-r--r--lua/telescope/_.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/lua/telescope/_.lua b/lua/telescope/_.lua
index dd73768..6b8b445 100644
--- a/lua/telescope/_.lua
+++ b/lua/telescope/_.lua
@@ -20,9 +20,14 @@ function AsyncJob.new(opts)
self.stdout = opts.stdout or M.NullPipe()
self.stderr = opts.stderr or M.NullPipe()
- if opts.cwd then
- -- TODO: not vim.fn
+ if opts.cwd and opts.cwd ~= "" then
self.uv_opts.cwd = vim.fn.expand(opts.cwd)
+ -- this is a "illegal" hack for windows. E.g. If the git command returns `/` rather than `\` as delimiter,
+ -- vim.fn.expand might just end up returning an empty string. Weird
+ -- Because empty string is not allowed in libuv the job will not spawn. Solution is we just set it to opts.cwd
+ if self.uv_opts.cwd == "" then
+ self.uv_opts.cwd = opts.cwd
+ end
end
self.uv_opts.stdio = {
@@ -57,8 +62,7 @@ end
M.spawn = function(opts)
local self = AsyncJob.new(opts)
-
- self.handle = uv.spawn(
+ self.handle, self.pid = uv.spawn(
self.command,
self.uv_opts,
async.void(function()
@@ -66,6 +70,10 @@ M.spawn = function(opts)
end)
)
+ if not self.handle then
+ error(debug.traceback("Failed to spawn process: " .. vim.inspect(self)))
+ end
+
return self
end