We always undo the last edit without any coalescing so the user can be sure that ⌘Z only undos the last thing they did. For redo though this makes less sense, although it does break symmetry, i.e. pressing ⌘Z n times will bring us back again by pressing ⇧⌘Z only n-1 times.