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

Function find

static/editor.md/lib/codemirror/lib/codemirror.js:1833–1846  ·  view source on GitHub ↗
(textNode, topNode, offset)

Source from the content-addressed store, hash-verified

1831 var measure = lineView.measure, maps = measure.maps;
1832
1833 function find(textNode, topNode, offset) {
1834 for (var i = -1; i < (maps ? maps.length : 0); i++) {
1835 var map = i < 0 ? measure.map : maps[i];
1836 for (var j = 0; j < map.length; j += 3) {
1837 var curNode = map[j + 2];
1838 if (curNode == textNode || curNode == topNode) {
1839 var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
1840 var ch = map[j] + offset;
1841 if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
1842 return Pos(line, ch);
1843 }
1844 }
1845 }
1846 }
1847 var found = find(textNode, topNode, offset);
1848 if (found) return badPos(found, bad);
1849

Callers 1

locateNodeInLineViewFunction · 0.70

Calls 1

lineNoFunction · 0.70

Tested by

no test coverage detected