Index: /trunk/src/org/openstreetmap/josm/command/SelectCommand.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/command/SelectCommand.java	(revision 12349)
+++ /trunk/src/org/openstreetmap/josm/command/SelectCommand.java	(revision 12350)
@@ -59,4 +59,6 @@
     @Override
     public void undoCommand() {
+        ensurePrimitivesAreInDataset();
+
         getAffectedDataSet().setSelected(oldSelection);
     }
@@ -64,7 +66,14 @@
     @Override
     public boolean executeCommand() {
+        ensurePrimitivesAreInDataset();
+
         oldSelection = getAffectedDataSet().getSelected();
         getAffectedDataSet().setSelected(newSelection);
         return true;
+    }
+
+    @Override
+    public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
+        return Collections.unmodifiableCollection(newSelection);
     }
 
Index: /trunk/test/unit/org/openstreetmap/josm/command/SelectCommandTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/command/SelectCommandTest.java	(revision 12349)
+++ /trunk/test/unit/org/openstreetmap/josm/command/SelectCommandTest.java	(revision 12350)
@@ -123,7 +123,7 @@
     @Test
     public void testGetParticipatingPrimitives() {
-        SelectCommand command = new SelectCommand(Arrays.asList(testData.existingNode, testData.existingWay));
+        SelectCommand command = new SelectCommand(Arrays.asList(testData.existingNode));
         command.executeCommand();
-        assertArrayEquals(new Object[] {}, command.getParticipatingPrimitives().toArray());
+        assertArrayEquals(new Object[] { testData.existingNode }, command.getParticipatingPrimitives().toArray());
     }
 
