diff options
Diffstat (limited to 'src/nvim/os/time.c')
-rw-r--r-- | src/nvim/os/time.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index a4871ef499..3794e813d2 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -6,6 +6,7 @@ #include <uv.h> #include "nvim/os/time.h" +#include "nvim/os/event.h" #include "nvim/vim.h" #include "nvim/term.h" @@ -38,31 +39,22 @@ uint64_t os_hrtime(void) /// @param ignoreinput If true, allow a SIGINT to interrupt us void os_delay(uint64_t milliseconds, bool ignoreinput) { - os_microdelay(milliseconds * 1000, ignoreinput); + if (ignoreinput) { + if (milliseconds > INT_MAX) { + milliseconds = INT_MAX; + } + event_poll_until((int)milliseconds, got_int); + } else { + os_microdelay(milliseconds * 1000); + } } /// Sleeps for a certain amount of microseconds /// /// @param microseconds Number of microseconds to sleep -/// @param ignoreinput If true, allow a SIGINT to interrupt us -void os_microdelay(uint64_t microseconds, bool ignoreinput) +void os_microdelay(uint64_t microseconds) { - int old_tmode; - - if (ignoreinput) { - // Go to cooked mode without echo, to allow SIGINT interrupting us - // here - old_tmode = curr_tmode; - - if (curr_tmode == TMODE_RAW) - settmode(TMODE_SLEEP); - - microdelay(microseconds); - - settmode(old_tmode); - } else { - microdelay(microseconds); - } + microdelay(microseconds); } /// Portable version of POSIX localtime_r() |