Index: trunk/src/org/openstreetmap/josm/data/validation/Test.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 5286)
+++ trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 5287)
@@ -12,5 +12,7 @@
 import javax.swing.JPanel;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.command.DeleteCommand;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -223,3 +225,23 @@
         return progressMonitor.isCanceled();
     }
+    
+    /**
+     * Build a Delete command on all primitives that have not yet been deleted manually by user, or by another error fix.
+     * If all primitives have already been deleted, null is returned.
+     * @param primitives The primitives wanted for deletion
+     * @return a Delete command on all primitives that have not yet been deleted, or null otherwise
+     */
+    protected final Command deletePrimitivesIfNeeded(Collection<? extends OsmPrimitive> primitives) {
+        Collection<OsmPrimitive> primitivesToDelete = new ArrayList<OsmPrimitive>();
+        for (OsmPrimitive p : primitives) {
+            if (!p.isDeleted()) {
+                primitivesToDelete.add(p);
+            }
+        }
+        if (!primitivesToDelete.isEmpty()) {
+            return DeleteCommand.delete(Main.map.mapView.getEditLayer(), primitivesToDelete);
+        } else {
+            return null;
+        }
+    }
 }
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java	(revision 5286)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java	(revision 5287)
@@ -373,18 +373,28 @@
         LinkedHashSet<Node> nodes = new LinkedHashSet<Node>(OsmPrimitive.getFilteredList(sel, Node.class));
 
-        // Use first existing node or first node if all nodes are new
-        Node target = null;
-        for (Node n: nodes) {
-            if (!n.isNew()) {
-                target = n;
-                break;
-            }
-        }
-        if (target == null) {
-            target = nodes.iterator().next();
-        }
-
-        if (DeleteCommand.checkAndConfirmOutlyingDelete(Main.main.getCurrentDataSet().getDataSourceArea(), nodes, Collections.singleton(target)))
-            return MergeNodesAction.mergeNodes(Main.main.getEditLayer(), nodes, target);
+        // Filter nodes that have already been deleted (see #5764 and #5773)
+        for (Iterator<Node> it = nodes.iterator(); it.hasNext();) {
+            if (it.next().isDeleted()) {
+                it.remove();
+            }
+        }
+
+        // Merge only if at least 2 nodes remain
+        if (nodes.size() >= 2) {
+            // Use first existing node or first node if all nodes are new
+            Node target = null;
+            for (Node n: nodes) {
+                if (!n.isNew()) {
+                    target = n;
+                    break;
+                }
+            }
+            if (target == null) {
+                target = nodes.iterator().next();
+            }
+    
+            if (DeleteCommand.checkAndConfirmOutlyingDelete(Main.main.getCurrentDataSet().getDataSourceArea(), nodes, Collections.singleton(target)))
+                return MergeNodesAction.mergeNodes(Main.main.getEditLayer(), nodes, target);
+        }
 
         return null;// undoRedo handling done in mergeNodes
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicatedWayNodes.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicatedWayNodes.java	(revision 5286)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicatedWayNodes.java	(revision 5287)
@@ -7,8 +7,6 @@
 import java.util.Collections;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.ChangeCommand;
 import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.command.DeleteCommand;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.Way;
@@ -61,5 +59,5 @@
         if (wnew.getNodesCount() < 2)
             // Empty way, delete
-            return DeleteCommand.delete(Main.map.mapView.getEditLayer(), Collections.singleton(w));
+            return deletePrimitivesIfNeeded(Collections.singleton(w));
         else
             return new ChangeCommand(w, wnew);
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java	(revision 5286)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedNode.java	(revision 5287)
@@ -8,7 +8,5 @@
 import java.util.Map;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.command.DeleteCommand;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -110,5 +108,5 @@
     @Override
     public Command fixError(TestError testError) {
-        return DeleteCommand.delete(Main.map.mapView.getEditLayer(), testError.getPrimitives());
+        return deletePrimitivesIfNeeded(testError.getPrimitives());
     }
 
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java	(revision 5286)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java	(revision 5287)
@@ -11,5 +11,4 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.command.DeleteCommand;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
@@ -142,5 +141,5 @@
     @Override
     public Command fixError(TestError testError) {
-        return DeleteCommand.delete(Main.map.mapView.getEditLayer(), testError.getPrimitives());
+        return deletePrimitivesIfNeeded(testError.getPrimitives());
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 5286)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java	(revision 5287)
@@ -25,5 +25,4 @@
 import javax.swing.JOptionPane;
 import javax.swing.JPopupMenu;
-import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
 import javax.swing.event.TreeSelectionEvent;
@@ -570,12 +569,16 @@
                     if (this.canceled)
                         return;
-                    final Command fixCommand = error.getFix();
-                    if (fixCommand != null) {
-                        SwingUtilities.invokeAndWait(new Runnable() {
-                            @Override
-                            public void run() {
-                                Main.main.undoRedo.addNoRedraw(fixCommand);
-                            }
-                        });
+                    if (error.isFixable()) {
+                        final Command fixCommand = error.getFix();
+                        if (fixCommand != null) {
+                            SwingUtilities.invokeAndWait(new Runnable() {
+                                @Override
+                                public void run() {
+                                    Main.main.undoRedo.addNoRedraw(fixCommand);
+                                }
+                            });
+                        }
+                        // It is wanted to ignore an error if it said fixable, even if fixCommand was null
+                        // This is to fix #5764 and #5773: a delete command, for example, may be null if all concerned primitives have already been deleted
                         error.setIgnored(true);
                     }
