Bug 128117 [Undo/Redo] Context not removed from TriggeredOperations
When I add a context to a TriggeredOperations using #addContext(IUndoContext), I cannot remove the same context using #removeContext(IUndoContext). This is because TriggeredOperations overrides #removeContext(IUndoContext) and only considers removing the context from its triggering operation or its children, but not from its own list of contexts. In my case, I have an editor that adds its undo context to operations that it wants to be able to present in its undo menu. When the editor closes, it flushes its undo context from the history. However, if the operation is a TriggeredOperations, the editor undo context is not removed, and the operation will never be flushed from the history.
bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/TriggeredOperations.java
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
/**
 * <p>
 * Triggered operations are a specialized implementation of a composite operation
 * that keeps track of operations triggered by the execution of some primary operation. 
 * The composite knows which operation was the trigger for subsequent operations, and 
 * adds all triggered operations as children. When execution, undo, or redo is performed, 
 * only the triggered operation is executed, undone, or redone if it is still present. If
 * the trigger is removed from the triggered operations, then the child operations will 
 * replace the triggered operations in the history.
 * </p>
 * <p>
 * This class may be instantiated by clients.
 * </p>
 * 
 * @since 3.1
 */
public final class TriggeredOperations extends AbstractOperation implements
		ICompositeOperation, IAdvancedUndoableOperation, IContextReplacingOperation {
	private IUndoableOperation triggeringOperation;
	private IOperationHistory history;
	private List children = new ArrayList();
	/**