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

Function shiftDoc

static/editor.md/lib/codemirror/lib/codemirror.js:4285–4297  ·  view source on GitHub ↗
(doc, distance)

Source from the content-addressed store, hash-verified

4283 // Sub-views need their line numbers shifted when text is added
4284 // above or below them in the parent document.
4285 function shiftDoc(doc, distance) {
4286 if (distance == 0) return;
4287 doc.first += distance;
4288 doc.sel = new Selection(map(doc.sel.ranges, function(range) {
4289 return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
4290 Pos(range.head.line + distance, range.head.ch));
4291 }), doc.sel.primIndex);
4292 if (doc.cm) {
4293 regChange(doc.cm, doc.first, doc.first - distance, distance);
4294 for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
4295 regLineChange(doc.cm, l, "gutter");
4296 }
4297 }
4298
4299 // More lower-level change function, handling only a single document
4300 // (not linked ones).

Callers 1

makeChangeSingleDocFunction · 0.70

Calls 3

mapFunction · 0.70
regChangeFunction · 0.70
regLineChangeFunction · 0.70

Tested by

no test coverage detected