mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
fix(vim.ui): open() may wait indefinitely #28325
Problem: vim.ui.open "locks up" Nvim if the spawned process does not terminate. #27986 Solution: - Change `vim.ui.open()`: - Do not call `wait()`. - Return a `SystemObj`. The caller can decide if it wants to `wait()`. - Change `gx` to `wait()` only a short time. - Allows `gx` to show a message if the command fails, without the risk of waiting forever.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
local t = require('test.functional.testutil')()
|
||||
local eq = t.eq
|
||||
local matches = t.matches
|
||||
local ok = t.ok
|
||||
local exec_lua = t.exec_lua
|
||||
local clear = t.clear
|
||||
local feed = t.feed
|
||||
@@ -138,13 +138,12 @@ describe('vim.ui', function()
|
||||
describe('open()', function()
|
||||
it('validation', function()
|
||||
if is_os('win') or not is_ci('github') then
|
||||
exec_lua [[vim.system = function() return { wait=function() return { code=3} end } end]]
|
||||
exec_lua [[vim.system = function() return { wait=function() return { code=3 } end } end]]
|
||||
end
|
||||
if not is_os('bsd') then
|
||||
matches(
|
||||
'vim.ui.open: command failed %(%d%): { "[^"]+", .*"non%-existent%-file" }',
|
||||
exec_lua [[local _, err = vim.ui.open('non-existent-file') ; return err]]
|
||||
)
|
||||
local rv =
|
||||
exec_lua [[local cmd = vim.ui.open('non-existent-file'); return cmd:wait(100).code]]
|
||||
ok(type(rv) == 'number' and rv ~= 0, 'nonzero exit code', rv)
|
||||
end
|
||||
|
||||
exec_lua [[
|
||||
|
||||
Reference in New Issue
Block a user