When using "set noimd" remember which input source was used in normal mode separately from the input source used in insert mode. This way it is possible to e.g. use a US layout in normal mode and a non-US layout in insert mode. The input source used in normal mode must be ASCII capable or it won't be remembered -- any input source used in insert mode is remembered. On 10.4 the IM code is unchanged because 10.4 does not support the Text Input Source Services.
This both cleans up the code as well as improve support for binding to more key combinations. The Cocoa key bindings system is effectively disabled; a custom key binding dictionary is set up in KeyBinding.plist (so that keyboard navigation works in dialogs).
Explicitly force the sheet animation to be performed before passing the result of the sheet on to the backend. Before this patch the animation was performed asynchronously and this could lead to a Vim controller being released at the same time as the animation was being performed since the animation took place in the default run loop mode.