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

Function lineAtHeight

external/.scrollLibs.js:1046–1071  ·  view source on GitHub ↗
(chunk, h)

Source from the content-addressed store, hash-verified

1044 // Find the line at the given vertical position, using the height
1045 // information in the document tree.
1046 function lineAtHeight(chunk, h) {
1047 var n = chunk.first
1048 outer: do {
1049 for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
1050 var child = chunk.children[i$1],
1051 ch = child.height
1052 if (h < ch) {
1053 chunk = child
1054 continue outer
1055 }
1056 h -= ch
1057 n += child.chunkSize()
1058 }
1059 return n
1060 } while (!chunk.lines)
1061 var i = 0
1062 for (; i < chunk.lines.length; ++i) {
1063 var line = chunk.lines[i],
1064 lh = line.height
1065 if (h < lh) {
1066 break
1067 }
1068 h -= lh
1069 }
1070 return n + i
1071 }
1072
1073 function isLine(doc, l) {
1074 return l >= doc.first && l < doc.first + doc.size

Callers 4

coordsCharFunction · 0.85
visibleLinesFunction · 0.85
gutterEventFunction · 0.85
addEditorMethodsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected