comparison src/ui.c @ 15665:31367ce5aac7 v8.1.0840

patch 8.1.0840: getchar(0) never returns a character in the terminal commit https://github.com/vim/vim/commit/12dfc9eef14fe74c46145aa9e6cba9666f1bcd40 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jan 28 22:32:58 2019 +0100 patch 8.1.0840: getchar(0) never returns a character in the terminal Problem: getchar(0) never returns a character in the terminal. Solution: Call wait_func() at least once.
author Bram Moolenaar <Bram@vim.org>
date Mon, 28 Jan 2019 22:45:05 +0100
parents 2202ab00e9f9
children 7fad90423bd2
comparison
equal deleted inserted replaced
15664:128d7a4ccd54 15665:31367ce5aac7
270 int (*wait_func)(long wtime, int *interrupted, int ignore_input), 270 int (*wait_func)(long wtime, int *interrupted, int ignore_input),
271 int (*resize_func)(int check_only)) 271 int (*resize_func)(int check_only))
272 { 272 {
273 int len; 273 int len;
274 int interrupted = FALSE; 274 int interrupted = FALSE;
275 int did_call_wait_func = FALSE;
275 int did_start_blocking = FALSE; 276 int did_start_blocking = FALSE;
276 long wait_time; 277 long wait_time;
277 long elapsed_time = 0; 278 long elapsed_time = 0;
278 #ifdef ELAPSED_FUNC 279 #ifdef ELAPSED_FUNC
279 elapsed_T start_tv; 280 elapsed_T start_tv;
311 wait_time = p_ut; 312 wait_time = p_ut;
312 #ifdef ELAPSED_FUNC 313 #ifdef ELAPSED_FUNC
313 elapsed_time = ELAPSED_FUNC(start_tv); 314 elapsed_time = ELAPSED_FUNC(start_tv);
314 #endif 315 #endif
315 wait_time -= elapsed_time; 316 wait_time -= elapsed_time;
316 if (wait_time <= 0) 317
318 // If the waiting time is now zero or less, we timed out. However,
319 // loop at least once to check for characters and events. Matters
320 // when "wtime" is zero.
321 if (wait_time <= 0 && did_call_wait_func)
317 { 322 {
318 if (wtime >= 0) 323 if (wtime >= 0)
319 // no character available within "wtime" 324 // no character available within "wtime"
320 return 0; 325 return 0;
321 326
372 wait_time = 100L; 377 wait_time = 100L;
373 #endif 378 #endif
374 379
375 // Wait for a character to be typed or another event, such as the winch 380 // Wait for a character to be typed or another event, such as the winch
376 // signal or an event on the monitored file descriptors. 381 // signal or an event on the monitored file descriptors.
382 did_call_wait_func = TRUE;
377 if (wait_func(wait_time, &interrupted, FALSE)) 383 if (wait_func(wait_time, &interrupted, FALSE))
378 { 384 {
379 // If input was put directly in typeahead buffer bail out here. 385 // If input was put directly in typeahead buffer bail out here.
380 if (typebuf_changed(tb_change_cnt)) 386 if (typebuf_changed(tb_change_cnt))
381 return 0; 387 return 0;