From 1ed1ccc2c35d6c18961a4077470b787575329811 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/gui_macvim.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index c6a8a16df2..ac0bb4944a 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -407,9 +407,19 @@ gui_mch_wait_for_chars(int wtime) [[MMBackend sharedInstance] flushQueue:YES]; #ifdef MESSAGE_QUEUE +# ifdef FEAT_TIMERS + did_add_timer = FALSE; +# endif parse_queued_messages(); +# ifdef FEAT_TIMERS + if (did_add_timer) + return FAIL; +# endif #endif + if (input_available()) + return OK; + return [[MMBackend sharedInstance] waitForInput:wtime]; } From cf2ddc70a1a0a6e1f475b45a4c9155183149cc98 Mon Sep 17 00:00:00 2001 From: ichizok Date: Fri, 18 Nov 2016 16:41:40 +0900 Subject: [PATCH 2/3] Check for jobs and channels more often --- src/MacVim/MMBackend.m | 38 ++++++++++++++++++++++++++++++++++++++ src/MacVim/gui_macvim.m | 2 ++ 2 files changed, 40 insertions(+) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 9f924be715..02f782ff71 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 @@ -682,6 +685,20 @@ extern GuiFont gui_mch_retain_font(GuiFont font); if ([inputQueue count]) { inputReceived = YES; } else { + NSTimer *timer = nil; + + // Set interval timer which checks for the events of job and channel + // when there is any pending job or channel. + if (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]; + } + // Wait for the specified amount of time, unless 'milliseconds' is // negative in which case we wait "forever" (1e6 seconds translates to // approximately 11 days). @@ -695,6 +712,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 +3026,22 @@ 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(); + +# ifdef FEAT_TIMERS + if (did_add_timer || input_available()) + CFRunLoopStop(CFRunLoopGetCurrent()); +# endif +} +#endif + @end // MMBackend (Private) diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index ac0bb4944a..77526db7bc 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -410,7 +410,9 @@ gui_mch_wait_for_chars(int wtime) # ifdef FEAT_TIMERS did_add_timer = FALSE; # endif + parse_queued_messages(); + # ifdef FEAT_TIMERS if (did_add_timer) return FAIL; From a6d11c71a052f086d8b5247d284ff1151f85205c Mon Sep 17 00:00:00 2001 From: ichizok Date: Thu, 17 Nov 2016 07:13:11 +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 808511ca8f..c21e617b1e 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1370,7 +1370,7 @@ function MyExitTimeCb(job, status) endfunction func Test_exit_callback_interval() - if !has('job') || has('gui_macvim') + if !has('job') return endif