This function was doing too many things, with behaviors fairly different
depending on its input parameters. This was making the code fragile and
hard to follow.
Split it in three:
- ed_undo_step_pre does the common actions before we actually undo data.
- ed_undo_step_post does the common actions after we have undone/redone data.
Then, ed_undo_step_direction, ed_undo_step_by_name and
ed_undo_step_by_index do their actual specific actions, with their own
logic.
Note: Since the actual behavior of those three funtions is fairly
different (the first only undo/redo one effective step, the second is only
supposed to undo before given named step, and the third actually
undo/redo until given indexed step become active), we could also find
better names for those. right now, it sounds like they are doing the
same thing, with just different ways to specify the target step.
Note: This is part of on-going refactor work on undo system, see T83806.