Index: trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java	(revision 3630)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java	(revision 3631)
@@ -54,5 +54,5 @@
 
     /**
-     * If true, when extruding create new node even if segments prallel.
+     * If true, when extruding create new node even if segments parallel.
      */
     private boolean alwaysCreateNodes = false;
@@ -142,5 +142,5 @@
     /**
      * If the left mouse button is pressed over a segment, switch
-     * to either extrude or translate mode depending on whether ctrl is held.
+     * to either extrude or translate mode depending on whether Ctrl is held.
      */
     @Override public void mousePressed(MouseEvent e) {
@@ -194,5 +194,5 @@
                         initialN2en.getY() - en.getY()));
             }
-            
+
             // Signifies that nothing has happened yet
             newN1en = null;
@@ -306,7 +306,8 @@
                     //find if the new points overlap existing segments (in case of 90 degree angles)
                     Node prevNode = getPreviousNode(selectedSegment.lowerIndex);
-                    boolean nodeOverlapsSegment = prevNode != null && pointsColinear(prevNode.getEastNorth(), initialN1en, newN1en);
-
-                    if (nodeOverlapsSegment && !alwaysCreateNodes) {
+                    boolean nodeOverlapsSegment = prevNode != null && segmentsParralel(initialN1en, prevNode.getEastNorth(), initialN1en, newN1en);
+                    boolean hasOtherWays = this.hasNodeOtherWays(selectedSegment.getFirstNode(), selectedSegment.way);
+
+                    if (nodeOverlapsSegment && !alwaysCreateNodes && !hasOtherWays) {
                         //move existing node
                         Node n1Old = selectedSegment.getFirstNode();
@@ -322,7 +323,8 @@
                     //find if the new points overlap existing segments (in case of 90 degree angles)
                     Node nextNode = getNextNode(selectedSegment.lowerIndex + 1);
-                    nodeOverlapsSegment = nextNode != null && pointsColinear(nextNode.getEastNorth(), initialN2en, newN2en);
-
-                    if (nodeOverlapsSegment && !alwaysCreateNodes) {
+                    nodeOverlapsSegment = nextNode != null && segmentsParralel(initialN2en, nextNode.getEastNorth(), initialN2en, newN2en);
+                    hasOtherWays = hasNodeOtherWays(selectedSegment.getFirstNode(), selectedSegment.way);
+
+                    if (nodeOverlapsSegment && !alwaysCreateNodes && !hasOtherWays) {
                         //move existing node
                         Node n2Old = selectedSegment.getSecondNode();
@@ -362,4 +364,18 @@
     }
 
+    /**
+     * This method tests if a node has other ways apart from the given one.
+     * @param node
+     * @param myWay
+     * @return true of node belongs only to myWay, false if there are more ways.
+     */
+    private boolean hasNodeOtherWays(Node node, Way myWay) {
+        for (OsmPrimitive p : node.getReferrers()) {
+            if (p instanceof Way && p.isUsable() && p != myWay)
+                return true;
+        }
+        return false;
+    }
+
     /***
      * This method calculates offset amount by witch to move the given segment perpendicularly for it to be in line with mouse position.
@@ -369,10 +385,7 @@
      * @return offset amount of P1 and P2.
      */
-    private static EastNorth calculateSegmentOffset(EastNorth segmentP1, EastNorth segmentP2 ,EastNorth moveDirection , EastNorth targetPos)
-    {
-        EastNorth intersectionPoint = getLineLineIntersection(
-                segmentP1,
-                segmentP2,
-                targetPos,
+    private static EastNorth calculateSegmentOffset(EastNorth segmentP1, EastNorth segmentP2, EastNorth moveDirection,
+            EastNorth targetPos) {
+        EastNorth intersectionPoint = getLineLineIntersection(segmentP1, segmentP2, targetPos,
                 new EastNorth(targetPos.getX() + moveDirection.getX(), targetPos.getY() + moveDirection.getY()));
 
@@ -381,15 +394,13 @@
         else
             //return distance form base to target position
-            return new EastNorth(targetPos.getX() - intersectionPoint.getX(), targetPos.getY() - intersectionPoint.getY());
-    }
-
-    /**
-     * Finds the intersection of two lines of inifinite length
-     * @return EastNorth null if no intersection was found, the Lon coordinates of the intersection otherwise
-     */
-    static public EastNorth getLineLineIntersection(
-            EastNorth p1, EastNorth p2,
-            EastNorth p3, EastNorth p4) {
-
+            return new EastNorth(targetPos.getX() - intersectionPoint.getX(),
+                        targetPos.getY() - intersectionPoint.getY());
+    }
+
+    /**
+     * Finds the intersection of two lines of infinite length.
+     * @return EastNorth null if no intersection was found, the coordinates of the intersection otherwise
+     */
+    public static EastNorth getLineLineIntersection(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
         // Convert line from (point, point) form to ax+by=c
         double a1 = p2.getY() - p1.getY();
@@ -402,40 +413,23 @@
 
         // Solve the equations
-        double det = a1*b2 - a2*b1;
-        if(det == 0) return null; // Lines are parallel
-
-        return new EastNorth(
-                (b1*c2 - b2*c1)/det,
-                (a2*c1 - a1*c2)/det);
-    }
-
-    /**
-     * Returns true if all points are on the same line.
-     */
-    private static boolean pointsColinear(EastNorth p1, EastNorth p2, EastNorth p3) {
-
-        //the simple dumb way of triangle side lengths.
-        double distance1 = p1.distance(p2);
-        double distance2 = p1.distance(p3);
-        double distance3 = p2.distance(p3);
-
-        //sort so that distance 1 is the greatest
-        if (distance1 < distance2) {
-            double temp = distance1;
-            distance1 = distance2;
-            distance2 = temp;
-        }
-
-        if (distance1 < distance3) {
-            double temp = distance1;
-            distance1 = distance3;
-            distance3 = temp;
-        }
-
-        //test with some treshold
-        double difference = distance1 - distance2 - distance3;
-
-        return (Math.abs(difference) < 1e-15);
-
+        double det = a1 * b2 - a2 * b1;
+        if (det == 0)
+            return null; // Lines are parallel
+
+        return new EastNorth((b1 * c2 - b2 * c1) / det, (a2 * c1 - a1 * c2) / det);
+    }
+
+    private static boolean segmentsParralel(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
+
+        // Convert line from (point, point) form to ax+by=c
+        double a1 = p2.getY() - p1.getY();
+        double b1 = p1.getX() - p2.getX();
+
+        double a2 = p4.getY() - p3.getY();
+        double b2 = p3.getX() - p4.getX();
+
+        // Solve the equations
+        double det = a1 * b2 - a2 * b1;
+        return Math.abs(det) < 1e-13;
     }
 
