Skip to content

Commit 8be5651

Browse files
committed
Limit loop in scrollPosIntoView at 5 steps
To prevent infinite loops when the algorithm somehow doesn't converge (It should converge, but infinite loops with nebulous termination conditions are a rather bad source of hangs.) I'm still torn about this, since it'll mask bugs. Issue #2819
1 parent 3d3898f commit 8be5651

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/codemirror.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3721,7 +3721,7 @@
37213721
// measured, the position of something may 'drift' during drawing).
37223722
function scrollPosIntoView(cm, pos, end, margin) {
37233723
if (margin == null) margin = 0;
3724-
for (;;) {
3724+
for (var limit = 0; limit < 5; limit++) {
37253725
var changed = false, coords = cursorCoords(cm, pos);
37263726
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
37273727
var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),

0 commit comments

Comments
 (0)