MCPcopy
hub / github.com/witheve/Eve / viewCuttingPoint

Function viewCuttingPoint

src/codemirror.js:3360–3382  ·  view source on GitHub ↗
(cm, oldN, newN, dir)

Source from the content-addressed store, hash-verified

3358 }
3359
3360 function viewCuttingPoint(cm, oldN, newN, dir) {
3361 var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
3362 if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
3363 return {index: index, lineN: newN};
3364 for (var i = 0, n = cm.display.viewFrom; i < index; i++)
3365 n += view[i].size;
3366 if (n != oldN) {
3367 if (dir > 0) {
3368 if (index == view.length - 1) return null;
3369 diff = (n + view[index].size) - oldN;
3370 index++;
3371 } else {
3372 diff = n - oldN;
3373 }
3374 oldN += diff; newN += diff;
3375 }
3376 while (visualLineNo(cm.doc, newN) != newN) {
3377 if (index == (dir < 0 ? 0 : view.length - 1)) return null;
3378 newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
3379 index += dir;
3380 }
3381 return {index: index, lineN: newN};
3382 }
3383
3384 // Force the view to cover a given range, adding empty view element
3385 // 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