From 8124b25f2bd9e19a4e90a879c53d301463103900 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Sat, 20 Oct 2007 19:33:16 +0200 Subject: [PATCH] Fix ":set go+=c" and menu autoenabling bugs. Bug: With 'go+=c' Vim could enter a key wait loop while processInput==TRUE which caused all keyboard input to be dropped. Fix: Don't drop keyboard input when processInput==TRUE Bug: With 'go+c' Vim disabled all menu items before quitting which caused autoenabling not to work so the "New Window" was sometimes grey when no windows were open. Fix: Enable all menu items in recurseSetAutoenablesItems. --- src/MacVim/MMAppController.m | 12 ++-- src/MacVim/MMBackend.h | 9 --- src/MacVim/MMBackend.m | 111 ++++++++++------------------------- 3 files changed, 39 insertions(+), 93 deletions(-) diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 26475a0107..bfbc8c7da1 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -315,12 +315,14 @@ static NSTimeInterval MMTerminateTimeout = 3; if (![vimControllers count]) { // Turn on autoenabling of menus (because no Vim is open to handle it), - // but do not touch the MacVim menu. + // but do not touch the MacVim menu. Note that the menus must be + // enabled first otherwise autoenabling does not work. NSMenu *mainMenu = [NSApp mainMenu]; int i, count = [mainMenu numberOfItems]; for (i = 1; i < count; ++i) { - NSMenu *submenu = [[mainMenu itemAtIndex:i] submenu]; - [submenu recurseSetAutoenablesItems:YES]; + NSMenuItem *item = [mainMenu itemAtIndex:i]; + [item setEnabled:YES]; + [[item submenu] recurseSetAutoenablesItems:YES]; } } } @@ -590,7 +592,9 @@ static NSTimeInterval MMTerminateTimeout = 3; int i, count = [self numberOfItems]; for (i = 0; i < count; ++i) { - NSMenu *submenu = [[self itemAtIndex:i] submenu]; + NSMenuItem *item = [self itemAtIndex:i]; + [item setEnabled:YES]; + NSMenu *submenu = [item submenu]; if (submenu) { [submenu recurseSetAutoenablesItems:on]; } diff --git a/src/MacVim/MMBackend.h b/src/MacVim/MMBackend.h index a432225c1e..86a55db16a 100644 --- a/src/MacVim/MMBackend.h +++ b/src/MacVim/MMBackend.h @@ -13,12 +13,6 @@ #import "vim.h" -// If disabled, all input is dropped if input is already being processed. (If -// enabled, same thing happens at the moment actually. So this is pretty -// useless.) -#define MM_USE_INPUT_QUEUE 0 - - @interface MMBackend : NSObject 0) { - // TODO: Dispatch these messages? Maybe not; usually when the - // 'inputQueue' is non-empty it means that a LOT of messages has been - // sent simultaneously. The only way this happens is when Vim is being - // tormented, e.g. if the user holds down to rapidly switch - // windows. - unsigned i; - for (i = 0; i < count; i+=2) { - int msgid = [[inputQueue objectAtIndex:i] intValue]; - NSLog(@"%s: Dropping message %s", _cmd, MessageStrings[msgid]); - } - - [inputQueue removeAllObjects]; - } -#endif - - inputReceived = YES; - inProcessInput = NO; -} - - (void)handleToggleToolbar { // If 'go' contains 'T', then remove it, else add it.