1
0
forked from aniani/vim

patch 8.0.1405: duplicated code for getting a typed character

Problem:    Duplicated code for getting a typed character. CursorHold is
            called too often in the GUI. (lilydjwg)
Solution:   Refactor code to move code up from mch_inchar().  Don't fire
            CursorHold if feedkeys() was used. (closes #2451)
This commit is contained in:
Bram Moolenaar
2017-12-18 18:14:47 +01:00
parent 606d45ccd8
commit c9e649ae81
7 changed files with 90 additions and 71 deletions

View File

@@ -5790,36 +5790,8 @@ mch_breakcheck(int force)
WaitForChar(long msec, int *interrupted, int ignore_input)
{
#ifdef FEAT_TIMERS
long due_time;
long remaining = msec;
int tb_change_cnt = typebuf.tb_change_cnt;
/* When waiting very briefly don't trigger timers. */
if (msec >= 0 && msec < 10L)
return WaitForCharOrMouse(msec, NULL, ignore_input);
while (msec < 0 || remaining > 0)
{
/* 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, interrupted, ignore_input))
return TRUE;
if (interrupted != NULL && *interrupted)
/* Nothing available, but need to return so that side effects get
* handled, such as handling a message on a channel. */
return FALSE;
if (msec > 0)
remaining -= due_time;
}
return FALSE;
return ui_wait_for_chars_or_timer(
msec, WaitForCharOrMouse, interrupted, ignore_input) == OK;
#else
return WaitForCharOrMouse(msec, interrupted, ignore_input);
#endif