Index: trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java	(revision 13107)
+++ trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java	(revision 13108)
@@ -173,5 +173,8 @@
 
         try {
-            MainApplication.undoRedo.add(buildCommand());
+            Command cmd = buildCommand(getLayerManager().getEditDataSet());
+            if (cmd != null) {
+                MainApplication.undoRedo.add(cmd);
+            }
         } catch (InvalidSelection except) {
             Logging.debug(except);
@@ -184,10 +187,10 @@
     /**
      * Builds "align in line" command depending on the selected objects.
+     * @param ds data set in which the command operates
      * @return the resulting command to execute to perform action
      * @throws InvalidSelection if a polygon is selected, or if a node is used by 3 or more ways
-     * @since 12562
-     */
-    public Command buildCommand() throws InvalidSelection {
-        DataSet ds = getLayerManager().getEditDataSet();
+     * @since 13108
+     */
+    public Command buildCommand(DataSet ds) throws InvalidSelection {
         List<Node> selectedNodes = new ArrayList<>(ds.getSelectedNodes());
         List<Way> selectedWays = new ArrayList<>(ds.getSelectedWays());
@@ -276,5 +279,5 @@
                 throw new InvalidSelection(tr("Intersection of three or more ways can not be solved. Abort."));
         }
-        return new SequenceCommand(tr("Align Nodes in Line"), cmds);
+        return cmds.isEmpty() ? null : new SequenceCommand(tr("Align Nodes in Line"), cmds);
     }
 
