diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-04-15 04:33:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-15 04:33:09 -0700 |
commit | 57adf8c6e01d9395eb52fe03571c535571efdc4b (patch) | |
tree | f5f999287509f2970c4f9034934fbecdfadb83ca /test/functional/lua/ui_spec.lua | |
parent | 4ec8fd43bfdf1924ee03e07afc8a46dfdd3c9b12 (diff) | |
download | rneovim-57adf8c6e01d9395eb52fe03571c535571efdc4b.tar.gz rneovim-57adf8c6e01d9395eb52fe03571c535571efdc4b.tar.bz2 rneovim-57adf8c6e01d9395eb52fe03571c535571efdc4b.zip |
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.
Diffstat (limited to 'test/functional/lua/ui_spec.lua')
-rw-r--r-- | test/functional/lua/ui_spec.lua | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/test/functional/lua/ui_spec.lua b/test/functional/lua/ui_spec.lua index 8c9148c6f5..71a04a9ae6 100644 --- a/test/functional/lua/ui_spec.lua +++ b/test/functional/lua/ui_spec.lua @@ -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 [[ |