Bug 161786 [Undo] - operations with multiple, matching contexts not disposed properly
Found this problem running the workspace operations automated tests. In that suite, a marker operation that changes a bookmark and a task is performed. The operation is therefore assigned two undo contexts "bookmark" and "task". These two undo contexts are set up to "match" against the workspace context. This is done so that only task ops show up in the task list undo history, only bookmark ops show up in the bookmark view undo history, but all of the marker ops show up in the workspace undo history. The problem occurs when I attempt to dispose the workspace context. In theory, this marker operation should be disposed, since both contexts match the workspace context. In practice it doesn't happen and I get this operation "stuck" in the undo history.
bundles/org.eclipse.core.commands/src/org/eclipse/core/commands/operations/DefaultOperationHistory.java
/*******************************************************************************
 * Copyright (c) 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.core.commands.operations;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.util.Tracing;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;