Missing method IEnumerable<IAction> SimpleHistory::EnumRedoableActions()

Oct 22, 2015 at 2:13 PM
The method IEnumerable<IAction> SimpleHistory::EnumUndoableActions() exists.
Why is its pendant EnumRedoableActions() missing?
Is there a technical reason for this?

The use-case is: I've built Undo-Stack and Redo-Stack pop-up UI controls, so that the user can choose and perform (multiple) Undo & Redo actions via the mouse. Exactly like in Excel.
To fill the Redo-Stack pop-up control, I of course need EnumRedoableActions().

I have created this myself with the following code:

public IEnumerable<IAction> EnumRedoableActions()
{
SimpleHistoryNode current = Head;
while (CanMoveForward && current.NextNode != null)
    current = current.NextNode;
while (current != null && current != CurrentState && current.PreviousAction != null)
{
    yield return current.PreviousAction;
    current = current.PreviousNode;
}
}

And it seems to work. Would you agree or have you any other comments?

Thanks in advance,
Mark
Coordinator
Oct 28, 2015 at 7:44 PM
I just added it - I moved the project to GitHub:
https://github.com/KirillOsenkov/Undo

I've also just published an updated NuGet package with the fix:
https://www.nuget.org/packages/guilabs.undo/

Here's the implementation I used:
    public IEnumerable<IAction> EnumRedoableActions()
    {
        SimpleHistoryNode current = CurrentState;
        while (current != null && current.NextAction != null)
        {
            yield return current.NextAction;
            current = current.NextNode;
        }
    }
Oct 29, 2015 at 10:53 AM
That seems to work and is more elegant.
Thanx!
Mark