Index: /trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 358)
+++ /trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java	(revision 359)
@@ -11,5 +11,8 @@
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 import java.util.LinkedList;
+import java.util.List;
 
 import javax.swing.JOptionPane;
@@ -80,5 +83,6 @@
 		Collection<Command> cmds = new LinkedList<Command>();
 
-		Way reuseWay = null, replacedWay = null;
+		ArrayList<Way> reuseWays = new ArrayList<Way>(),
+			replacedWays = new ArrayList<Way>();
 		boolean newNode = false;
 		Node n = Main.map.mapView.getNearestNode(e.getPoint());
@@ -94,8 +98,30 @@
 			cmds.add(new AddCommand(n));
 
-			WaySegment ws = Main.map.mapView.getNearestWaySegment(e.getPoint());
-			if (ws != null) {
-				replacedWay = ws.way;
-				reuseWay = splitWaySegmentAtNode(ws, n, cmds);
+			// Insert the node into all the nearby way segments
+			List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(e.getPoint());
+			Map<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>();
+			for (WaySegment ws : wss) {
+				List<Integer> is;
+				if (insertPoints.containsKey(ws.way)) {
+					is = insertPoints.get(ws.way);
+				} else {
+					is = new ArrayList<Integer>();
+					insertPoints.put(ws.way, is);
+				}
+
+				is.add(ws.lowerIndex);
+			}
+			for (Map.Entry<Way, List<Integer>> insertPoint : insertPoints.entrySet()) {
+				Way w = insertPoint.getKey();
+				List<Integer> is = insertPoint.getValue();
+
+				Way wnew = new Way(w);
+
+				pruneSuccsAndReverse(is);
+				for (int i : is) wnew.nodes.add(i + 1, n);
+
+				cmds.add(new ChangeCommand(insertPoint.getKey(), wnew));
+				replacedWays.add(insertPoint.getKey());
+				reuseWays.add(wnew);
 			}
 		}
@@ -111,6 +137,7 @@
 				cmds.add(new AddCommand(way));
 			} else {
-				if (way == replacedWay) {
-					way = reuseWay;
+				int i;
+				if ((i = replacedWays.indexOf(way)) != -1) {
+					way = reuseWays.get(i);
 				} else {
 					Way wnew = new Way(way);
@@ -133,5 +160,5 @@
 			return; // We didn't do anything.
 		} else if (!extendedWay) {
-			if (reuseWay == null) {
+			if (reuseWays.isEmpty()) {
 				title = tr("Add node");
 			} else {
@@ -140,5 +167,5 @@
 		} else if (!newNode) {
 			title = tr("Connect existing way to node");
-		} else if (reuseWay == null) {
+		} else if (reuseWays.isEmpty()) {
 			title = tr("Add a new node to an existing way");
 		} else {
@@ -171,10 +198,18 @@
 		return way;
 	}
-	
-	private Way splitWaySegmentAtNode(WaySegment ws, Node n, Collection<Command> cmds) {
-		Way wnew = new Way(ws.way);
-		wnew.nodes.add(ws.lowerIndex + 1, n);
-		cmds.add(new ChangeCommand(ws.way, wnew));
-		return wnew;
+
+	private static void pruneSuccsAndReverse(List<Integer> is) {
+		//if (is.size() < 2) return;
+
+		HashSet<Integer> is2 = new HashSet<Integer>();
+		for (int i : is) {
+			if (!is2.contains(i - 1) && !is2.contains(i + 1)) {
+				is2.add(i);
+			}
+		}
+		is.clear();
+		is.addAll(is2);
+		Collections.sort(is);
+		Collections.reverse(is);
 	}
 }
Index: /trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java	(revision 358)
+++ /trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java	(revision 359)
@@ -5,4 +5,7 @@
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.TreeMap;
+import java.util.List;
+import java.util.ArrayList;
 
 import javax.swing.JComponent;
@@ -145,15 +148,11 @@
 
 	/**
-	 * @return the nearest way segment to the screen point given that is not 
-	 * in ignore.
+	 * @return all way segments within 10px of p, sorted by their
+	 * perpendicular distance.
 	 * 
 	 * @param p the point for which to search the nearest segment.
-	 * @param ignore a collection of segments which are not to be returned.
-	 * May be null.
-	 */
-	public final WaySegment getNearestWaySegment(Point p, Collection<WaySegment> ignore) {
-		Way minPrimitive = null;
-		int minI = 0;
-		double minDistanceSq = Double.MAX_VALUE;
+	 */
+	public final List<WaySegment> getNearestWaySegments(Point p) {
+		TreeMap<Double, WaySegment> nearest = new TreeMap<Double, WaySegment>();
 		for (Way w : Main.ds.ways) {
 			if (w.deleted)
@@ -168,21 +167,33 @@
 					continue;
 				}
-				if (ignore == null || !ignore.contains(new WaySegment(w, i))) {
-					Point A = getPoint(lastN.eastNorth);
-					Point B = getPoint(n.eastNorth);
-					double c = A.distanceSq(B);
-					double a = p.distanceSq(B);
-					double b = p.distanceSq(A);
-					double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared
-					if (perDist < 100 && minDistanceSq > perDist && a < c+100 && b < c+100) {
-						minDistanceSq = perDist;
-						minPrimitive = w;
-						minI = i;
-					}
-				}
+
+				Point A = getPoint(lastN.eastNorth);
+				Point B = getPoint(n.eastNorth);
+				double c = A.distanceSq(B);
+				double a = p.distanceSq(B);
+				double b = p.distanceSq(A);
+				double perDist = a-(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared
+				if (perDist < 100 && a < c+100 && b < c+100) {
+					nearest.put(perDist, new WaySegment(w, i));
+				}
+
 				lastN = n;
 			}
 		}
-		return minPrimitive == null ? null : new WaySegment(minPrimitive, minI);
+		return new ArrayList<WaySegment>(nearest.values());
+	}
+
+	/**
+	 * @return the nearest way segment to the screen point given that is not 
+	 * in ignore.
+	 * 
+	 * @param p the point for which to search the nearest segment.
+	 * @param ignore a collection of segments which are not to be returned.
+	 * May be null.
+	 */
+	public final WaySegment getNearestWaySegment(Point p, Collection<WaySegment> ignore) {
+		List<WaySegment> nearest = getNearestWaySegments(p);
+		if (ignore != null) nearest.removeAll(ignore);
+		return nearest.isEmpty() ? null : nearest.get(0);
 	}
 
