diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-04-20 20:18:23 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-04-20 20:18:23 +0200 |
commit | 40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8 (patch) | |
tree | 59056726cfbcd9afe1b71eab0db0f30ac61856f4 /src/os_unix.c | |
parent | 245c41070c7f37d52be43cce0cb140bd3ade6c7e (diff) |
patch 7.4.1759v7.4.1759
Problem: When using feedkeys() in a timer the inserted characters are not
used right away.
Solution: Break the wait loop when characters have been added to typebuf.
use this for testing CursorHoldI.
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 58a27da050..f8cf691d1f 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -397,7 +397,7 @@ mch_inchar( if (wtime >= 0) { - while (WaitForChar(wtime) == 0) /* no character available */ + while (!WaitForChar(wtime)) /* no character available */ { if (do_resize) handle_resize(); @@ -420,7 +420,7 @@ mch_inchar( * flush all the swap files to disk. * Also done when interrupted by SIGWINCH. */ - if (WaitForChar(p_ut) == 0) + if (!WaitForChar(p_ut)) { #ifdef FEAT_AUTOCMD if (trigger_cursorhold() && maxlen >= 3 @@ -448,7 +448,7 @@ mch_inchar( * We want to be interrupted by the winch signal * or by an event on the monitored file descriptors. */ - if (WaitForChar(-1L) == 0) + if (!WaitForChar(-1L)) { if (do_resize) /* interrupted by SIGWINCH signal */ handle_resize(); @@ -482,7 +482,7 @@ handle_resize(void) } /* - * return non-zero if a character is available + * Return non-zero if a character is available. */ int mch_char_avail(void) @@ -5210,7 +5210,7 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED) /* See above for type of argv. */ execvp(argv[0], argv); - perror("executing job failed"); + // perror("executing job failed"); _exit(EXEC_FAILED); /* exec failed, return failure code */ } @@ -5359,6 +5359,7 @@ mch_breakcheck(void) * "msec" == -1 will block forever. * Invokes timer callbacks when needed. * When a GUI is being used, this will never get called -- webb + * Returns TRUE when a character is available. */ static int WaitForChar(long msec) @@ -5367,6 +5368,7 @@ WaitForChar(long msec) long due_time; long remaining = msec; int break_loop = FALSE; + int tb_change_cnt = typebuf.tb_change_cnt; /* When waiting very briefly don't trigger timers. */ if (msec >= 0 && msec < 10L) @@ -5377,6 +5379,11 @@ WaitForChar(long msec) /* Trigger timers and then get the time in msec until the next one is * due. Wait up to that time. */ due_time = check_due_timer(); + if (typebuf.tb_change_cnt != tb_change_cnt) + { + /* timer may have used feedkeys() */ + return FALSE; + } if (due_time <= 0 || (msec > 0 && due_time > remaining)) due_time = remaining; if (WaitForCharOrMouse(due_time, &break_loop)) |