Index: /trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java	(revision 7225)
+++ /trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java	(revision 7226)
@@ -55,4 +55,5 @@
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Shortcut;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -80,6 +81,6 @@
     private boolean ignoreSharedNodes;
 
-    private final boolean keepSegmentDirection;
-    
+    private boolean keepSegmentDirection;
+
     /**
      * drawing settings for helper lines
@@ -100,5 +101,5 @@
      * Collection of nodes that is moved
      */
-    private ArrayList<OsmPrimitive> movingNodeList;
+    private ArrayList<Node> movingNodeList;
 
     /**
@@ -150,6 +151,4 @@
     /** The cursor for the 'alwaysCreateNodes' submode. */
     private final Cursor cursorCreateNodes;
-
-    private boolean ignoreNextKeyRelease;
 
     private static class ReferenceSegment {
@@ -179,4 +178,6 @@
     /** Dual alignment reference segments */
     private ReferenceSegment dualAlignSegment1, dualAlignSegment2;
+    /** {@code true}, if new segment was collapsed */
+    private boolean dualAlignSegmentCollapsed;
     // Dual alignment UI stuff
     private final DualAlignChangeAction dualAlignChangeAction;
@@ -184,4 +185,5 @@
     private final Shortcut dualAlignShortcut;
     private boolean useRepeatedShortcut;
+    private boolean ignoreNextKeyRelease;
 
     private class DualAlignChangeAction extends JosmAction {
@@ -219,6 +221,5 @@
         dualAlignShortcut = Shortcut.registerShortcut("mapmode:extrudedualalign",
                 tr("Mode: {0}", tr("Extrude Dual alignment")), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE);
-        useRepeatedShortcut = Main.pref.getBoolean("extrude.dualalign.toggleOnRepeatedX", true);
-        keepSegmentDirection = Main.pref.getBoolean("extrude.dualalign.keep-segment-direction", true);
+        readPreferences(); // to show prefernces in table before entering the mode
     }
 
@@ -250,6 +251,10 @@
             rv = new StringBuilder(tr("Drag a way segment to make a rectangle. Ctrl-drag to move a segment along its normal, " +
                 "Alt-drag to create a new rectangle, double click to add a new node."));
-            if (dualAlignEnabled)
+            if (dualAlignEnabled) {
                 rv.append(" ").append(tr("Dual alignment active."));
+                if (dualAlignSegmentCollapsed) {
+                    rv.append(" ").append(tr("Segment collapsed due to its direction reversing."));
+ 	        }
+            }
         } else {
             if (mode == Mode.translate)
@@ -281,4 +286,11 @@
         Main.map.mapView.addMouseListener(this);
         Main.map.mapView.addMouseMotionListener(this);
+        readPreferences();
+        ignoreNextKeyRelease = true;
+        Main.map.keyDetector.addKeyListener(this);
+        Main.map.keyDetector.addModifierListener(this);
+    }
+
+    private void readPreferences() {
         initialMoveDelay = Main.pref.getInteger("edit.initial-move-delay",200);
         initialMoveThreshold = Main.pref.getInteger("extrude.initial-move-threshold", 1);
@@ -295,7 +307,6 @@
         ignoreSharedNodes = Main.pref.getBoolean("extrude.ignore-shared-nodes", true);
         dualAlignCheckboxMenuItem.getAction().setEnabled(true);
-        ignoreNextKeyRelease = true;
-        Main.map.keyDetector.addKeyListener(this);
-        Main.map.keyDetector.addModifierListener(this);
+        useRepeatedShortcut = Main.pref.getBoolean("extrude.dualalign.toggleOnRepeatedX", true);
+        keepSegmentDirection = Main.pref.getBoolean("extrude.dualalign.keep-segment-direction", true);
     }
 
@@ -392,4 +403,5 @@
                 dualAlignActive = true;
                 calculatePossibleDirectionsForDualAlign();
+                dualAlignSegmentCollapsed = false;
             } else {
                 dualAlignActive = false;
@@ -451,5 +463,5 @@
             EastNorth mouseEn = Main.map.mapView.getEastNorth(e.getPoint().x, e.getPoint().y);
             EastNorth bestMovement = calculateBestMovementAndNewNodes(mouseEn);
-            
+
             Main.map.mapView.setNewCursor(Cursor.MOVE_CURSOR, this);
 
@@ -480,5 +492,5 @@
                     if (moveCommand == null) {
                         //make a new move command
-                        moveCommand = new MoveCommand(movingNodeList, bestMovement.getX(), bestMovement.getY());
+                        moveCommand = new MoveCommand(new ArrayList<OsmPrimitive>(movingNodeList), bestMovement);
                         Main.main.undoRedo.add(moveCommand);
                     } else {
@@ -522,4 +534,5 @@
                 //Commit translate
                 //the move command is already committed in mouseDragged
+                joinNodesIfCollapsed(movingNodeList);
             }
 
@@ -531,5 +544,4 @@
             moveCommand = null;
             mode = Mode.select;
-
             updateStatusLine();
             Main.map.mapView.repaint();
@@ -589,5 +601,5 @@
      * Does actual extrusion of {@link #selectedSegment}.
      * Uses {@link #initialN1en}, {@link #initialN2en} saved in calculatePossibleDirections* call
-     * Uses {@link #newN1en}, {@link #newN2en} calculated by {@link #calculateBestMovementAndNewNodes} 
+     * Uses {@link #newN1en}, {@link #newN2en} calculated by {@link #calculateBestMovementAndNewNodes}
      */
     private void performExtrusion() {
@@ -671,9 +683,19 @@
         Command c = new SequenceCommand(tr("Extrude Way"), cmds);
         Main.main.undoRedo.add(c);
+        joinNodesIfCollapsed(changedNodes);
+    }
+
+    private void joinNodesIfCollapsed(List<Node> changedNodes) {
         if (newN1en.distance(newN2en) < 1e-6) {
             // If the dual alignment created moved two nodes  to the same point, merge them
             Node targetNode = MergeNodesAction.selectTargetNode(changedNodes);
-            Command mergeCmd = MergeNodesAction.mergeNodes(Main.main.getEditLayer(), changedNodes, targetNode, changedNodes.get(0));
-            Main.main.undoRedo.add(mergeCmd);
+            Node locNode = MergeNodesAction.selectTargetLocationNode(changedNodes);
+            Command mergeCmd = MergeNodesAction.mergeNodes(Main.main.getEditLayer(), changedNodes, targetNode, locNode);
+            if (mergeCmd!=null) {
+                Main.main.undoRedo.add(mergeCmd);
+            } else {
+                // undo extruding command itself
+                Main.main.undoRedo.undo();
+            }
         }
     }
@@ -866,5 +888,5 @@
             ), initialN2en,  nextNodeEn, false);
     }
-    
+
     /**
      * Calculate newN1en, newN2en best suitable for given mouse coordinates
@@ -881,5 +903,5 @@
         Main.map.statusLine.setDist(distance);
         updateStatusLine();
-        
+
         if (dualAlignActive) {
             // new positions of selected segment's nodes, without applying dual alignment
@@ -895,4 +917,7 @@
                 newN1en = collapsedSegmentPosition;
                 newN2en = collapsedSegmentPosition;
+                dualAlignSegmentCollapsed = true;
+            } else {
+                dualAlignSegmentCollapsed = false;
             }
         } else {
@@ -1064,5 +1089,5 @@
         return normalUnitVector;
     }
-    
+
     /**
      * Returns true if from1-to1 and from2-to2 vertors directions are opposite
