From 27e4d1d62d4d91b3fb96d2cc7b3c9b8fde4dc3c3 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 23 Jun 2019 16:19:13 -0700 Subject: [PATCH] Revert "Revert "Don't service ioport completions if data is available on stdin"" This reverts commit 005e6f2ab8cf2dd9a2c7801d0bd02729a1535233. This allows new text entry to take priority over highlighting, improving the performance of pasting. --- src/input_common.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/input_common.cpp b/src/input_common.cpp index c9457fe9a..b7bd37f10 100644 --- a/src/input_common.cpp +++ b/src/input_common.cpp @@ -104,13 +104,6 @@ char_event_t input_event_queue_t::readb() { } } - if (ioport > 0 && FD_ISSET(ioport, &fdset)) { - iothread_service_completion(); - if (auto mc = pop_discard_timeouts()) { - return *mc; - } - } - if (FD_ISSET(STDIN_FILENO, &fdset)) { unsigned char arr[1]; if (read_blocked(0, arr, 1) != 1) { @@ -121,6 +114,15 @@ char_event_t input_event_queue_t::readb() { // We read from stdin, so don't loop. return arr[0]; } + + // Check for iothread completions only if there is no data to be read from the stdin. + // This gives priority to the foreground. + if (ioport > 0 && FD_ISSET(ioport, &fdset)) { + iothread_service_completion(); + if (auto mc = pop_discard_timeouts()) { + return *mc; + } + } } } }