mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
fix(vim.ui.open): try wslview before explorer.exe #28424
Problem: explorer.exe is unreliable on WSL. Solution: Try wslview before explorer.exe. fix #28410
This commit is contained in:
parent
0ea38c9a53
commit
fd085d9082
@ -149,12 +149,14 @@ function M.open(path)
|
|||||||
else
|
else
|
||||||
return nil, 'vim.ui.open: rundll32 not found'
|
return nil, 'vim.ui.open: rundll32 not found'
|
||||||
end
|
end
|
||||||
|
elseif vim.fn.executable('wslview') == 1 then
|
||||||
|
cmd = { 'wslview', path }
|
||||||
elseif vim.fn.executable('explorer.exe') == 1 then
|
elseif vim.fn.executable('explorer.exe') == 1 then
|
||||||
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 }
|
||||||
else
|
else
|
||||||
return nil, 'vim.ui.open: no handler found (tried: 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, { text = true, detach = true }), nil
|
||||||
|
@ -151,7 +151,7 @@ describe('vim.ui', function()
|
|||||||
vim.fn.executable = function() return 0 end
|
vim.fn.executable = function() return 0 end
|
||||||
]]
|
]]
|
||||||
eq(
|
eq(
|
||||||
'vim.ui.open: no handler found (tried: explorer.exe, xdg-open)',
|
'vim.ui.open: no handler found (tried: wslview, explorer.exe, xdg-open)',
|
||||||
exec_lua [[local _, err = vim.ui.open('foo') ; return err]]
|
exec_lua [[local _, err = vim.ui.open('foo') ; return err]]
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user