From fa4bd6994df83cc68ecd7cc836ec9472efe1e351 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 12 Aug 2024 01:03:48 -0600 Subject: [PATCH 1/2] fix(lua): ignore stdout and stderr for xdg-open Ref #19724 Fix #29932 --- runtime/lua/vim/ui.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index ce583c25af..be46cc60ff 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -140,6 +140,9 @@ function M.open(path) end local cmd --- @type string[] + local opts --- @type vim.SystemOpts + + opts = { text = true, detach = true } if vim.fn.has('mac') == 1 then cmd = { 'open', path } @@ -155,11 +158,13 @@ function M.open(path) cmd = { 'explorer.exe', path } elseif vim.fn.executable('xdg-open') == 1 then cmd = { 'xdg-open', path } + opts.stdout = false + opts.stderr = false else return nil, 'vim.ui.open: no handler found (tried: wslview, explorer.exe, xdg-open)' end - return vim.system(cmd, { text = true, detach = true }), nil + return vim.system(cmd, opts), nil end return M From d63d379eecd6acd95e92e2e8b50729adb3c3a453 Mon Sep 17 00:00:00 2001 From: Yi Ming Date: Sun, 8 Sep 2024 05:14:37 +0800 Subject: [PATCH 2/2] fix(vim.ui.open): prefer xdg-open on WSL #30302 xdg-open is usually not installed in WSL. But if the user deliberately installs it, presumably they want to prioritize it. --- runtime/lua/vim/ui.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index be46cc60ff..43adb2e906 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -152,14 +152,14 @@ function M.open(path) else return nil, 'vim.ui.open: rundll32 not found' end - elseif vim.fn.executable('wslview') == 1 then - cmd = { 'wslview', path } - elseif vim.fn.executable('explorer.exe') == 1 then - cmd = { 'explorer.exe', path } elseif vim.fn.executable('xdg-open') == 1 then cmd = { 'xdg-open', path } opts.stdout = false opts.stderr = false + elseif vim.fn.executable('wslview') == 1 then + cmd = { 'wslview', path } + elseif vim.fn.executable('explorer.exe') == 1 then + cmd = { 'explorer.exe', path } else return nil, 'vim.ui.open: no handler found (tried: wslview, explorer.exe, xdg-open)' end