fix(lua): ignore stdout and stderr for xdg-open

Ref #19724
Fix #29932
This commit is contained in:
Aaron 2024-08-12 01:03:48 -06:00 committed by GitHub
parent 37d97e771e
commit 65a703e060
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -140,6 +140,9 @@ function M.open(path)
end end
local cmd --- @type string[] local cmd --- @type string[]
local opts --- @type vim.SystemOpts
opts = { text = true, detach = true }
if vim.fn.has('mac') == 1 then if vim.fn.has('mac') == 1 then
cmd = { 'open', path } cmd = { 'open', path }
@ -155,11 +158,13 @@ function M.open(path)
cmd = { 'explorer.exe', path } cmd = { 'explorer.exe', path }
elseif vim.fn.executable('xdg-open') == 1 then elseif vim.fn.executable('xdg-open') == 1 then
cmd = { 'xdg-open', path } cmd = { 'xdg-open', path }
opts.stdout = false
opts.stderr = false
else else
return nil, 'vim.ui.open: no handler found (tried: wslview, explorer.exe, xdg-open)' return nil, 'vim.ui.open: no handler found (tried: wslview, explorer.exe, xdg-open)'
end end
return vim.system(cmd, { text = true, detach = true }), nil return vim.system(cmd, opts), nil
end end
--- Gets the URL at cursor, if any. --- Gets the URL at cursor, if any.