瀏覽代碼

[shgraph] fix link creation inside comments

Clement Espeute 1 年之前
父節點
當前提交
db84be9424
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      hide/view/Graph.hx

+ 7 - 3
hide/view/Graph.hx

@@ -526,15 +526,19 @@ class Graph extends FileView {
 		var minDistNode = NODE_TRIGGER_NEAR;
 
 		// checking nearest box
-		var nearestBox = listOfBoxes[0];
-		var minDist = distanceToBox(nearestBox, clientX, clientY);
-		for (i in 1...listOfBoxes.length) {
+		var nearestBox = null;
+		var minDist = 999999999999999.0;
+		for (i in 0...listOfBoxes.length) {
+			if (listOfBoxes[i].comment != null)
+				continue;
 			var tmpDist = distanceToBox(listOfBoxes[i], clientX, clientY);
 			if (tmpDist < minDist) {
 				minDist = tmpDist;
 				nearestBox = listOfBoxes[i];
 			}
 		}
+		if (nearestBox == null)
+			return;
 
 		// checking nearest node in the nearest box
 		if (isCreatingLink == FromInput) {