From 03c5dada39c38acba2cfc97d353939e45e4942bd Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Thu, 14 Aug 2008 19:11:58 +0200 Subject: [PATCH] Insert Vim state message first on output queue when flushing --- src/MacVim/MMBackend.m | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index ae71b3cc81..02b02dcebc 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -93,7 +93,7 @@ static NSString *MMSymlinkWarningString = @interface MMBackend (Private) - (void)waitForDialogReturn; -- (void)queueVimStateMessage; +- (void)insertVimStateMessage; - (void)processInputQueue; - (void)handleInputEvent:(int)msgid data:(NSData *)data; + (NSDictionary *)specialKeys; @@ -519,11 +519,8 @@ static NSString *MMSymlinkWarningString = [drawData setLength:0]; } - if ([outputQueue count] > 0 || force) { - // When 'force' is set we always update the Vim state to ensure that - // MacVim has a copy of the latest state (since 'force' is typically - // set just before Vim takes a nap whilst waiting for input). - [self queueVimStateMessage]; + if ([outputQueue count] > 0) { + [self insertVimStateMessage]; @try { [frontendProxy processCommandQueue:outputQueue]; @@ -1612,7 +1609,7 @@ static NSString *MMSymlinkWarningString = } } -- (void)queueVimStateMessage +- (void)insertVimStateMessage { // NOTE: This is the place to add Vim state that needs to be accessed from // MacVim. Do not add state that could potentially require lots of memory @@ -1627,7 +1624,11 @@ static NSString *MMSymlinkWarningString = [NSNumber numberWithBool:[self unusedEditor]], @"unusedEditor", nil]; - [self queueMessage:SetVimStateMsgID data:[vimState dictionaryAsData]]; + // Put the state before all other messages. + int msgid = SetVimStateMsgID; + [outputQueue insertObject:[vimState dictionaryAsData] atIndex:0]; + [outputQueue insertObject:[NSData dataWithBytes:&msgid length:sizeof(int)] + atIndex:0]; } - (void)processInputQueue