diff options
-rw-r--r-- | src/nvim/eval.c | 16 | ||||
-rw-r--r-- | test/functional/eval/wait_spec.lua | 11 |
2 files changed, 9 insertions, 18 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b1012961f1..79e67f6d7b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10895,15 +10895,11 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) // Dummy timer callback. Used by f_wait(). static void dummy_timer_due_cb(TimeWatcher *tw, void *data) { - if (!uv_timer_get_repeat(&tw->uv)) { - time_watcher_start(tw, dummy_timer_due_cb, 0, 0); - } } // Dummy timer close callback. Used by f_wait(). static void dummy_timer_close_cb(TimeWatcher *tw, void *data) { - multiqueue_free(tw->events); xfree(tw); } @@ -10914,7 +10910,7 @@ static void f_wait(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_number = -1; if (argvars[0].v_type != VAR_NUMBER) { - EMSG2(_(e_invarg2), "First argument of wait() must be a number"); + EMSG2(_(e_invargval), "1"); return; } @@ -10928,20 +10924,18 @@ static void f_wait(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (tv_interval->v_type == VAR_NUMBER) { interval = tv_interval->vval.v_number; - if (interval < 0) { - EMSG2(_(e_invarg2), - "Third argument of wait() must be a non-negative number"); + if (interval <= 0) { + EMSG2(_(e_invargval), "3"); return; } // Start dummy timer tw = xmalloc(sizeof(TimeWatcher)); time_watcher_init(&main_loop, tw, NULL); - tw->events = multiqueue_new_child(main_loop.events); + tw->events = main_loop.events; tw->blockable = true; time_watcher_start(tw, dummy_timer_due_cb, interval, interval); } else if (tv_interval->v_type != VAR_UNKNOWN) { - EMSG2(_(e_invarg2), - "Third argument of wait() must be a non-negative number"); + EMSG2(_(e_invargval), "3"); return; } diff --git a/test/functional/eval/wait_spec.lua b/test/functional/eval/wait_spec.lua index c454774bbd..5bb27131f5 100644 --- a/test/functional/eval/wait_spec.lua +++ b/test/functional/eval/wait_spec.lua @@ -64,18 +64,15 @@ describe('wait()', function() nvim('set_var', 'counter', 0) eq(0, call('wait', 1000, 'Count() >= 5', 5)) eq(5, nvim('get_var', 'counter')) - - nvim('set_var', 'counter', 0) - eq(0, call('wait', 1000, 'Count() >= 5', 0)) - eq(5, nvim('get_var', 'counter')) end) it('errors out on invalid timeout value', function() - expect_err('E475: Invalid argument', call, 'wait', '', 1) + expect_err('Invalid value for argument', call, 'wait', '', 1) end) it('errors out on invalid interval', function() - expect_err('E475: Invalid argument', call, 'wait', 0, 1, -1) - expect_err('E475: Invalid argument', call, 'wait', 0, 1, '') + expect_err('Invalid value for argument', call, 'wait', 0, 1, -1) + expect_err('Invalid value for argument', call, 'wait', 0, 1, 0) + expect_err('Invalid value for argument', call, 'wait', 0, 1, '') end) end) |