Index: trunk/src/org/openstreetmap/josm/gui/dialogs/CommandListMutableTreeNode.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/CommandListMutableTreeNode.java	(revision 13942)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/CommandListMutableTreeNode.java	(revision 13943)
@@ -13,15 +13,12 @@
 
     protected final transient PseudoCommand cmd;
-    protected final int idx;
 
     /**
      * Constructs a new {@code CommandListMutableTreeNode}.
      * @param cmd command
-     * @param idx index
      */
-    public CommandListMutableTreeNode(PseudoCommand cmd, int idx) {
+    public CommandListMutableTreeNode(PseudoCommand cmd) {
         super(new JLabel(cmd.getDescriptionText(), cmd.getDescriptionIcon(), JLabel.HORIZONTAL));
         this.cmd = cmd;
-        this.idx = idx;
     }
 
@@ -39,5 +36,5 @@
      */
     public int getIndex() {
-        return idx;
+        return getParent().getIndex(this);
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java	(revision 13942)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java	(revision 13943)
@@ -273,5 +273,5 @@
         undoRoot = new DefaultMutableTreeNode();
         for (int i = 0; i < undoCommands.size(); ++i) {
-            undoRoot.add(getNodeForCommand(undoCommands.get(i), i));
+            undoRoot.add(getNodeForCommand(undoCommands.get(i)));
         }
         undoTreeModel.setRoot(undoRoot);
@@ -282,5 +282,5 @@
         redoRoot = new DefaultMutableTreeNode();
         for (int i = 0; i < redoCommands.size(); ++i) {
-            redoRoot.add(getNodeForCommand(redoCommands.get(i), i));
+            redoRoot.add(getNodeForCommand(redoCommands.get(i)));
         }
         redoTreeModel.setRoot(redoRoot);
@@ -330,13 +330,12 @@
      * Recursively adds child commands.
      * @param c the command
-     * @param idx index
      * @return the resulting node
      */
-    protected CommandListMutableTreeNode getNodeForCommand(PseudoCommand c, int idx) {
-        CommandListMutableTreeNode node = new CommandListMutableTreeNode(c, idx);
+    protected CommandListMutableTreeNode getNodeForCommand(PseudoCommand c) {
+        CommandListMutableTreeNode node = new CommandListMutableTreeNode(c);
         if (c.getChildren() != null) {
             List<PseudoCommand> children = new ArrayList<>(c.getChildren());
             for (int i = 0; i < children.size(); ++i) {
-                node.add(getNodeForCommand(children.get(i), i));
+                node.add(getNodeForCommand(children.get(i)));
             }
         }
@@ -371,5 +370,5 @@
     public void commandAdded(CommandAddedEvent e) {
         if (isVisible()) {
-            undoRoot.add(getNodeForCommand(e.getCommand(), undoRoot.getChildCount()));
+            undoRoot.add(getNodeForCommand(e.getCommand()));
             undoTreeModel.nodeStructureChanged(undoRoot);
             ensureTreesConsistency();
