Fix broken undo history when hitting enter during insert