Below is a sample program for this issue.
Undo operations give unexpected results when executing another command in the doExecute() method.
In this example, this command leaves two histories for undo.
The first undo operation returns the model to the state before executing the command.
The second undo operation returns the model to the state after executing the command.
public class IssueSampleCommand extends RecordingCommand {
private AddShapeCommand command;
private final EditingDomain domain;
public IssueSampleCommand(final EditingDomain domain, final URI modelUri, final GPoint classPosition, final Supplier<? extends EObject> supplier) {
super((TransactionalEditingDomain) domain);
this.command = new AddShapeCommand(domain, modelUri, classPosition, supplier);
this.domain = domain;
}
@Override
protected void doExecute() {
// This code occurs error when undo
domain.getCommandStack().execute(command);
}
}
Steps to Reproduce:
Below is a sample program to reproduce this problem.
Bug Description:
Below is a sample program for this issue. Undo operations give unexpected results when executing another command in the
doExecute()
method. In this example, this command leaves two histories for undo. The first undo operation returns the model to the state before executing the command. The second undo operation returns the model to the state after executing the command.Steps to Reproduce:
Below is a sample program to reproduce this problem.
Sample Program
This sample program is based on Coffee Editor and executes the above IssueSampleCommand instead of AddShapeCommand in AddAutomatedTaskCompoundCommand.