Clarification needed on ChangeHistory::SetWaypoint page


On this page:

It is claimed that:

In order for the waypoints to work correctly, you need to set one both before AND after you perform the action that should be able to be undone.

What is actually meant here (I assume) is that if you have one plugin that doesn’t use ChangeHistoryService and performs work A, then you have another plugin that performs work B and sets a waypoint properly, then if you undo it will revert both work A and B rather than just work B.

This should be documented as such; the reader should not be misled into thinking the function doesn’t properly set a waypoint when you only call it once after the work, just because of some plugins that don’t correctly use ChangeHistoryService. Describing why you actually might want to call twice will improve the quality of the description and make the functionality of SetWaypoint clearer.

It should also be documented that SetWaypoint will not actually create a waypoint if no changes were made since the last waypoint. (Otherwise, it is not clear that I won’t have to undo twice when I set a waypoint before and after the work.)

PS: Also, the same text appears above and below the code in the article.


My interpretation is that you need a waypoint before and after in order for Ctrl-Y or redo to work. Just a guess though, I def agree this needs clarification.


You do not, that’s why I’m asking for this to be clarified. You would only need to do before and after to fix the mess of other plugins not using waypoints properly. In a perfect world where all your plugins put a waypoint after the action they perform, everything would work just fine (undo/redo), yet the wiki does not explain this (it insinuates you need to do 2 waypoints regardless).