Index: trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 12592)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 12593)
@@ -181,5 +181,5 @@
      * set would have to be checked.
      */
-    private transient Set<OsmPrimitive> oldHighlights = new HashSet<>();
+    private transient Optional<OsmPrimitive> currentHighlight = Optional.empty();
 
     /**
@@ -257,5 +257,5 @@
         determineMapMode(c.isPresent());
 
-        Set<OsmPrimitive> newHighlights = new HashSet<>();
+        Optional<OsmPrimitive> newHighlight = Optional.empty();
 
         virtualManager.clear();
@@ -267,5 +267,5 @@
             mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this);
             // don't highlight anything else if a virtual node will be
-            return repaintIfRequired(newHighlights);
+            return repaintIfRequired(newHighlight);
         }
 
@@ -274,5 +274,5 @@
         // return early if there can't be any highlights
         if (!drawTargetHighlight || mode != Mode.MOVE || !c.isPresent())
-            return repaintIfRequired(newHighlights);
+            return repaintIfRequired(newHighlight);
 
         // CTRL toggles selection, but if while dragging CTRL means merge
@@ -282,7 +282,7 @@
             // when clicked. I.e. don't highlight selected elements unless
             // we are in toggle mode.
-            newHighlights.add(c.get());
-        }
-        return repaintIfRequired(newHighlights);
+            newHighlight = c;
+        }
+        return repaintIfRequired(newHighlight);
     }
 
@@ -354,33 +354,20 @@
             ds.clearHighlightedVirtualNodes();
         }
-        if (oldHighlights.isEmpty())
+        if (!currentHighlight.isPresent()) {
             return needsRepaint;
-
-        for (OsmPrimitive prim : oldHighlights) {
-            prim.setHighlighted(false);
-        }
-        oldHighlights = new HashSet<>();
+        } else {
+            currentHighlight.get().setHighlighted(false);
+        }
+        currentHighlight = Optional.empty();
         return true;
     }
 
-    private boolean repaintIfRequired(Set<OsmPrimitive> newHighlights) {
-        if (!drawTargetHighlight)
+    private boolean repaintIfRequired(Optional<OsmPrimitive> newHighlight) {
+        if (!drawTargetHighlight || currentHighlight.equals(newHighlight))
             return false;
-
-        boolean needsRepaint = false;
-        for (OsmPrimitive x : newHighlights) {
-            if (oldHighlights.contains(x)) {
-                continue;
-            }
-            needsRepaint = true;
-            x.setHighlighted(true);
-        }
-        oldHighlights.removeAll(newHighlights);
-        for (OsmPrimitive x : oldHighlights) {
-            x.setHighlighted(false);
-            needsRepaint = true;
-        }
-        oldHighlights = newHighlights;
-        return needsRepaint;
+        currentHighlight.ifPresent(osm -> osm.setHighlighted(false));
+        newHighlight.ifPresent(osm -> osm.setHighlighted(true));
+        currentHighlight = newHighlight;
+        return true;
     }
 
@@ -521,5 +508,5 @@
             if (p != null) {
                 p.setHighlighted(true);
-                oldHighlights.add(p);
+                currentHighlight = Optional.of(p);
                 needsRepaint = true;
             }
