(cm, pos, end, margin)
| 2693 | } |
| 2694 | |
| 2695 | function scrollPosIntoView(cm, pos, end, margin) { |
| 2696 | if (margin == null) margin = 0; |
| 2697 | for (;;) { |
| 2698 | var changed = false, coords = cursorCoords(cm, pos); |
| 2699 | var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); |
| 2700 | var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left), |
| 2701 | Math.min(coords.top, endCoords.top) - margin, |
| 2702 | Math.max(coords.left, endCoords.left), |
| 2703 | Math.max(coords.bottom, endCoords.bottom) + margin); |
| 2704 | var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; |
| 2705 | if (scrollPos.scrollTop != null) { |
| 2706 | setScrollTop(cm, scrollPos.scrollTop); |
| 2707 | if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true; |
| 2708 | } |
| 2709 | if (scrollPos.scrollLeft != null) { |
| 2710 | setScrollLeft(cm, scrollPos.scrollLeft); |
| 2711 | if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true; |
| 2712 | } |
| 2713 | if (!changed) return coords; |
| 2714 | } |
| 2715 | } |
| 2716 | |
| 2717 | function scrollIntoView(cm, x1, y1, x2, y2) { |
| 2718 | var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2); |
no test coverage detected