Index: applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java
===================================================================
--- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java	(revision 34769)
+++ applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java	(revision 34770)
@@ -30,7 +30,7 @@
     }
 
-    private int myAutomaticSelectionHash;
     private Collection<OsmPrimitive> lastSel;
     private int index;
+
     @Override
     public void actionPerformed(ActionEvent e) {
@@ -39,16 +39,18 @@
             LinkedList<Collection<? extends OsmPrimitive>> history = ds.getSelectionHistory();
             if (history == null || history.isEmpty()) return; // empty history
+            if (lastSel != null) {
+            	Collection<OsmPrimitive> selection = ds.getSelected();
+            	if (selection.containsAll(lastSel) && lastSel.containsAll(selection)) {
+            		// repeated action
+            	} else {
+            		index = -1;
+            	}
+            }
+
             int num = history.size();
+            int k = 0;
 
-            Collection<OsmPrimitive> selection = ds.getSelected();
-
-            if (selection != null && selection.hashCode() != myAutomaticSelectionHash) {
-                // manual selection or another pluging selection noticed
-                index = history.indexOf(lastSel);
-                // first is selected, next list is previous selection
-            }
-            int k = 0;
             Set<OsmPrimitive> newsel = new HashSet<>();
-            do {
+            while (k < num) {
                 if (index+1 < history.size()) index++; else index = 0;
                 Collection<? extends OsmPrimitive> histsel = history.get(index);
@@ -56,13 +58,18 @@
                 newsel.clear();
                 newsel.addAll(histsel);
-                newsel.retainAll(ds.allNonDeletedPrimitives());
-                if (!newsel.isEmpty()) break;
+                newsel.removeIf(p -> p == null || p.isDeleted());
                 k++;
-            } while (k < num);
+                if (!newsel.isEmpty()) {
+                	if (newsel.containsAll(ds.getSelected()) && ds.getSelected().containsAll(newsel)) {
+                		// ignore no-change selection
+                		continue;
+                	}
+                	break;
+                }
+            }
 
+            // set new selection (is added to history)
             ds.setSelected(newsel);
             lastSel = ds.getSelected();
-            myAutomaticSelectionHash = lastSel.hashCode();
-            // remember last automatic selection
         }
     }
@@ -70,5 +77,8 @@
     @Override
     protected void updateEnabledState() {
-        setEnabled(getLayerManager().getEditDataSet() != null);
+    	DataSet ds = getLayerManager().getEditDataSet();
+    	lastSel = null;
+    	index = -1;
+		setEnabled(ds != null && ds.getSelectionHistory().isEmpty());
     }
 }
