From 362a5c0b39ca463b623177536c787ce3983928e8 Mon Sep 17 00:00:00 2001 From: ichizok Date: Thu, 17 Nov 2016 05:36:07 +0900 Subject: [PATCH 1/3] Fix feedkeys in timer callback --- src/MacVim/MMBackend.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 9f924be715..65edd0ea6b 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -679,7 +679,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font); // Only start the run loop if the input queue is empty, otherwise process // the input first so that the input on queue isn't delayed. - if ([inputQueue count]) { + if ([inputQueue count] || input_available()) { inputReceived = YES; } else { // Wait for the specified amount of time, unless 'milliseconds' is From 235364e825a49a7fb5c7757c6de3258e65d7e413 Mon Sep 17 00:00:00 2001 From: ichizok Date: Sat, 19 Nov 2016 16:29:02 +0900 Subject: [PATCH 2/3] Check for jobs and channels more often --- src/MacVim/MMBackend.m | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 65edd0ea6b..9446d3cd7f 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -198,6 +198,9 @@ extern GuiFont gui_mch_retain_font(GuiFont font); #ifdef FEAT_BEVAL - (void)bevalCallback:(id)sender; #endif +#ifdef MESSAGE_QUEUE +- (void)checkForProcessEvents:(NSTimer *)timer; +#endif @end @@ -686,6 +689,19 @@ extern GuiFont gui_mch_retain_font(GuiFont font); // negative in which case we wait "forever" (1e6 seconds translates to // approximately 11 days). CFTimeInterval dt = (milliseconds >= 0 ? .001*milliseconds : 1e6); + NSTimer *timer = nil; + + // Set interval timer which checks for the events of job and channel + // when there is any pending job or channel. + if (dt > 0.1 && (has_any_channel() || has_pending_job())) { + timer = [NSTimer scheduledTimerWithTimeInterval:0.1 + target:self + selector:@selector(checkForProcessEvents:) + userInfo:nil + repeats:YES]; + [[NSRunLoop currentRunLoop] addTimer:timer + forMode:NSDefaultRunLoopMode]; + } while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, dt, true) == kCFRunLoopRunHandledSource) { @@ -695,6 +711,11 @@ extern GuiFont gui_mch_retain_font(GuiFont font); dt = 0.0; inputReceived = YES; } + + if (input_available()) + inputReceived = YES; + + [timer invalidate]; } // The above calls may have placed messages on the input queue so process @@ -3004,6 +3025,24 @@ extern GuiFont gui_mch_retain_font(GuiFont font); } #endif +#ifdef MESSAGE_QUEUE +- (void)checkForProcessEvents:(NSTimer *)timer +{ +# ifdef FEAT_TIMERS + did_add_timer = FALSE; +# endif + + parse_queued_messages(); + + if (input_available() +# ifdef FEAT_TIMERS + || did_add_timer +# endif + ) + CFRunLoopStop(CFRunLoopGetCurrent()); +} +#endif + @end // MMBackend (Private) From c8b6fd59f0a7703df434787383132b9cdb92cd8e Mon Sep 17 00:00:00 2001 From: ichizok Date: Sat, 19 Nov 2016 16:29:43 +0900 Subject: [PATCH 3/3] Enable Test_exit_callback_interval() --- src/testdir/test_channel.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 7fd0003db3..42e0e04b81 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1396,7 +1396,7 @@ function MyExitTimeCb(job, status) endfunction func Test_exit_callback_interval() - if !has('job') || has('gui_macvim') + if !has('job') return endif