MCPcopy Create free account
hub / github.com/TruthHun/BookStack / lineAtHeight

Function lineAtHeight

static/editor.md/lib/codemirror/lib/codemirror.js:7586–7603  ·  view source on GitHub ↗
(chunk, h)

Source from the content-addressed store, hash-verified

7584 // Find the line at the given vertical position, using the height
7585 // information in the document tree.
7586 function lineAtHeight(chunk, h) {
7587 var n = chunk.first;
7588 outer: do {
7589 for (var i = 0; i < chunk.children.length; ++i) {
7590 var child = chunk.children[i], ch = child.height;
7591 if (h < ch) { chunk = child; continue outer; }
7592 h -= ch;
7593 n += child.chunkSize();
7594 }
7595 return n;
7596 } while (!chunk.lines);
7597 for (var i = 0; i < chunk.lines.length; ++i) {
7598 var line = chunk.lines[i], lh = line.height;
7599 if (h < lh) break;
7600 h -= lh;
7601 }
7602 return n + i;
7603 }
7604
7605
7606 // Find the height above the given line.

Callers 4

visibleLinesFunction · 0.70
coordsCharFunction · 0.70
gutterEventFunction · 0.70
codemirror.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected