Skip to content

Commit 6606ba4

Browse files
committed
Break coordsCharInner loop if diff is 0
Closes codemirror#4786.
1 parent 782fd40 commit 6606ba4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/measurement/position_measurement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function coordsCharInner(cm, lineObj, lineNo, x, y) {
479479
steps = Math.min(steps, Math.ceil(Math.abs(diff) / diff_change_per_step))
480480
dir = diff < 0 ? 1 : -1
481481
}
482-
} while (steps > 1 || ((dir < 0) != (diff < 0) && (Math.abs(diff) <= Math.abs(prevDiff))))
482+
} while (diff != 0 && (steps > 1 || ((dir < 0) != (diff < 0) && (Math.abs(diff) <= Math.abs(prevDiff)))))
483483
if (Math.abs(diff) > Math.abs(prevDiff)) {
484484
if ((diff < 0) == (prevDiff < 0)) throw new Error("Broke out of infinite loop in coordsCharInner")
485485
pos = prevPos

0 commit comments

Comments
 (0)