MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / lineAtHeight

Function lineAtHeight

static/js/codemirror/codemirror.js:4605–4622  ·  view source on GitHub ↗
(chunk, h)

Source from the content-addressed store, hash-verified

4603 }
4604
4605 function lineAtHeight(chunk, h) {
4606 var n = chunk.first;
4607 outer: do {
4608 for (var i = 0, e = chunk.children.length; i < e; ++i) {
4609 var child = chunk.children[i], ch = child.height;
4610 if (h < ch) { chunk = child; continue outer; }
4611 h -= ch;
4612 n += child.chunkSize();
4613 }
4614 return n;
4615 } while (!chunk.lines);
4616 for (var i = 0, e = chunk.lines.length; i < e; ++i) {
4617 var line = chunk.lines[i], lh = line.height;
4618 if (h < lh) break;
4619 h -= lh;
4620 }
4621 return n + i;
4622 }
4623
4624 function heightAtLine(cm, lineObj) {
4625 lineObj = visualLine(cm.doc, lineObj);

Callers 3

visibleLinesFunction · 0.85
coordsCharFunction · 0.85
clickInGutterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected