MCPcopy Create free account
hub / github.com/breck7/scroll / ensureLineHeights

Function ensureLineHeights

external/.scrollLibs.js:3583–3601  ·  view source on GitHub ↗
(cm, lineView, rect)

Source from the content-addressed store, hash-verified

3581 // line. When lineWrapping is on, there might be more than one
3582 // height.
3583 function ensureLineHeights(cm, lineView, rect) {
3584 var wrapping = cm.options.lineWrapping
3585 var curWidth = wrapping && displayWidth(cm)
3586 if (!lineView.measure.heights || (wrapping && lineView.measure.width != curWidth)) {
3587 var heights = (lineView.measure.heights = [])
3588 if (wrapping) {
3589 lineView.measure.width = curWidth
3590 var rects = lineView.text.firstChild.getClientRects()
3591 for (var i = 0; i < rects.length - 1; i++) {
3592 var cur = rects[i],
3593 next = rects[i + 1]
3594 if (Math.abs(cur.bottom - next.bottom) > 2) {
3595 heights.push((cur.bottom + next.top) / 2 - rect.top)
3596 }
3597 }
3598 }
3599 heights.push(rect.bottom - rect.top)
3600 }
3601 }
3602
3603 // Find a line map (mapping character offsets to text nodes) and a
3604 // measurement cache for the given line number. (A line view might

Callers 1

measureCharPreparedFunction · 0.85

Calls 1

displayWidthFunction · 0.85

Tested by

no test coverage detected