MCPcopy Index your code
hub / github.com/witheve/Eve / ensureLineHeights

Function ensureLineHeights

src/codemirror.js:2545–2561  ·  view source on GitHub ↗
(cm, lineView, rect)

Source from the content-addressed store, hash-verified

2543 // line. When lineWrapping is on, there might be more than one
2544 // height.
2545 function ensureLineHeights(cm, lineView, rect) {
2546 var wrapping = cm.options.lineWrapping;
2547 var curWidth = wrapping && displayWidth(cm);
2548 if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
2549 var heights = lineView.measure.heights = [];
2550 if (wrapping) {
2551 lineView.measure.width = curWidth;
2552 var rects = lineView.text.firstChild.getClientRects();
2553 for (var i = 0; i < rects.length - 1; i++) {
2554 var cur = rects[i], next = rects[i + 1];
2555 if (Math.abs(cur.bottom - next.bottom) > 2)
2556 heights.push((cur.bottom + next.top) / 2 - rect.top);
2557 }
2558 }
2559 heights.push(rect.bottom - rect.top);
2560 }
2561 }
2562
2563 // Find a line map (mapping character offsets to text nodes) and a
2564 // 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