editor: Finalize current action group when mode is set.

This simple rule restores correct undo behaviour on most commands (eg.
2d2w deletes 4 words and gets undone with a single 'u')