--- ./src/LYMainLoop.c.pre	Sat Dec  5 20:31:12 1998
+++ ./src/LYMainLoop.c	Sun Dec  6 01:10:48 1998
@@ -2408,7 +2408,27 @@ new_cmd:  /*
 		int newlink = -1;
 		for (i = curdoc.link; i >= 0; i--) {
 		    if (links[i].ly < links[curdoc.link].ly) {
-			newlink = i;
+			int cy = links[i].ly, best, dist = 1000000;
+			int ox = links[curdoc.link].lx;
+
+			if (links[curdoc.link].hightext) 
+			    ox += strlen(links[curdoc.link].hightext)/2;
+
+			while (i >= 0 && cy == links[i].ly) {
+			    int cx = links[i].lx;
+			    
+			    if (links[i].hightext) 
+				cx += strlen(links[i].hightext)/2;
+			    cx -= ox;
+			    if (cx < 0)
+				cx = -cx;
+			    if (cx < dist) {
+				dist = cx;
+				best = i;
+			    }
+			    i--;
+			}
+			newlink = best;
 			break;
 		    }
 		}
@@ -2463,7 +2483,27 @@ new_cmd:  /*
 		int newlink = -1;
 		for (i = curdoc.link; i < nlinks; i++)
 		   if (links[i].ly > links[curdoc.link].ly) {
-			newlink = i;
+			int cy = links[i].ly, best, dist = 1000000;
+			int ox = links[curdoc.link].lx;
+
+			if (links[curdoc.link].hightext) 
+			    ox += strlen(links[curdoc.link].hightext)/2;
+
+			while (i < nlinks && cy == links[i].ly) {
+			    int cx = links[i].lx;
+			    
+			    if (links[i].hightext) 
+				cx += strlen(links[i].hightext)/2;
+			    cx -= ox;
+			    if (cx < 0)
+				cx = -cx;
+			    if (cx < dist) {
+				dist = cx;
+				best = i;
+			    }
+			    i++;
+			}
+			newlink = best;
 			break;
 		   }
 
