diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-12-30 19:49:59 +0100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2022-12-30 19:56:11 +0100 |
commit | 09370eae7756b07bb8f1f116b690b22aec7ec563 (patch) | |
tree | 2bd937bae9748d54cff50da0c091503b663fe997 /src/nvim/ex_docmd.c | |
parent | 4ace9e7e417fe26c8b73ff1d6042e6e4f3df9ebf (diff) | |
download | rneovim-09370eae7756b07bb8f1f116b690b22aec7ec563.tar.gz rneovim-09370eae7756b07bb8f1f116b690b22aec7ec563.tar.bz2 rneovim-09370eae7756b07bb8f1f116b690b22aec7ec563.zip |
refactor(sleep): simplify rube goldberg implementation of :sleep
As neovim does have event handling, we are checking for CTRL-C
all the time, not once per second.
Also, do_sleep() reimplements the same loop as
LOOP_PROCESS_EVENTS_UNTIL() already contains internally. Fix the latter
to use the right integer type, so we do not need the extra indirection.
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index b99df64a3d..dfe43610ad 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5658,15 +5658,11 @@ static void ex_sleep(exarg_T *eap) do_sleep(len); } -/// Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. +/// Sleep for "msec" milliseconds, but return early on CTRL-C. void do_sleep(long msec) { ui_flush(); // flush before waiting - for (long left = msec; !got_int && left > 0; left -= 1000L) { - int next = left > 1000L ? 1000 : (int)left; - LOOP_PROCESS_EVENTS_UNTIL(&main_loop, main_loop.events, (int)next, got_int); - os_breakcheck(); - } + LOOP_PROCESS_EVENTS_UNTIL(&main_loop, main_loop.events, msec, got_int); // If CTRL-C was typed to interrupt the sleep, drop the CTRL-C from the // input buffer, otherwise a following call to input() fails. |