summaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-28 22:32:58 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-28 22:32:58 +0100
commit12dfc9eef14fe74c46145aa9e6cba9666f1bcd40 (patch)
tree3a3c98030644028f710d33d7c2b2558ac0f2db13 /src/ui.c
parentf58d81a18752cb9bf899b3f7328fc489cf6558e8 (diff)
downloadvim-git-12dfc9eef14fe74c46145aa9e6cba9666f1bcd40.tar.gz
patch 8.1.0840: getchar(0) never returns a character in the terminalv8.1.0840
Problem: getchar(0) never returns a character in the terminal. Solution: Call wait_func() at least once.
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ui.c b/src/ui.c
index d4278a39f..0823d2dd2 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -272,6 +272,7 @@ inchar_loop(
{
int len;
int interrupted = FALSE;
+ int did_call_wait_func = FALSE;
int did_start_blocking = FALSE;
long wait_time;
long elapsed_time = 0;
@@ -313,7 +314,11 @@ inchar_loop(
elapsed_time = ELAPSED_FUNC(start_tv);
#endif
wait_time -= elapsed_time;
- if (wait_time <= 0)
+
+ // If the waiting time is now zero or less, we timed out. However,
+ // loop at least once to check for characters and events. Matters
+ // when "wtime" is zero.
+ if (wait_time <= 0 && did_call_wait_func)
{
if (wtime >= 0)
// no character available within "wtime"
@@ -374,6 +379,7 @@ inchar_loop(
// Wait for a character to be typed or another event, such as the winch
// signal or an event on the monitored file descriptors.
+ did_call_wait_func = TRUE;
if (wait_func(wait_time, &interrupted, FALSE))
{
// If input was put directly in typeahead buffer bail out here.