MCPcopy Index your code
hub / github.com/csev/py4e / viewCuttingPoint

Function viewCuttingPoint

tools/pythonauto/static/codemirrorepl/codemirror.js:2122–2143  ·  view source on GitHub ↗
(cm, oldN, newN, dir)

Source from the content-addressed store, hash-verified

2120 }
2121
2122 function viewCuttingPoint(cm, oldN, newN, dir) {
2123 var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
2124 if (!sawCollapsedSpans) return {index: index, lineN: newN};
2125 for (var i = 0, n = cm.display.viewFrom; i < index; i++)
2126 n += view[i].size;
2127 if (n != oldN) {
2128 if (dir > 0) {
2129 if (index == view.length - 1) return null;
2130 diff = (n + view[index].size) - oldN;
2131 index++;
2132 } else {
2133 diff = n - oldN;
2134 }
2135 oldN += diff; newN += diff;
2136 }
2137 while (visualLineNo(cm.doc, newN) != newN) {
2138 if (index == (dir < 0 ? 0 : view.length - 1)) return null;
2139 newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
2140 index += dir;
2141 }
2142 return {index: index, lineN: newN};
2143 }
2144
2145 // Force the view to cover a given range, adding empty view element
2146 // or clipping off existing ones as needed.

Callers 1

regChangeFunction · 0.85

Calls 2

findViewIndexFunction · 0.85
visualLineNoFunction · 0.85

Tested by

no test coverage detected