MCPcopy
hub / github.com/DHTMLX/gantt / viewCuttingPoint

Function viewCuttingPoint

samples/common/codehighlight/codemirror.js:3077–3100  ·  view source on GitHub ↗
(cm, oldN, newN, dir)

Source from the content-addressed store, hash-verified

3075 }
3076
3077 function viewCuttingPoint(cm, oldN, newN, dir) {
3078 var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
3079 if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
3080 { return {index: index, lineN: newN} }
3081 var n = cm.display.viewFrom;
3082 for (var i = 0; i < index; i++)
3083 { n += view[i].size; }
3084 if (n != oldN) {
3085 if (dir > 0) {
3086 if (index == view.length - 1) { return null }
3087 diff = (n + view[index].size) - oldN;
3088 index++;
3089 } else {
3090 diff = n - oldN;
3091 }
3092 oldN += diff; newN += diff;
3093 }
3094 while (visualLineNo(cm.doc, newN) != newN) {
3095 if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
3096 newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
3097 index += dir;
3098 }
3099 return {index: index, lineN: newN}
3100 }
3101
3102 // Force the view to cover a given range, adding empty view element
3103 // 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