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

Function shiftDoc

src/codemirror.js:4487–4499  ·  view source on GitHub ↗
(doc, distance)

Source from the content-addressed store, hash-verified

4485 // Sub-views need their line numbers shifted when text is added
4486 // above or below them in the parent document.
4487 function shiftDoc(doc, distance) {
4488 if (distance == 0) return;
4489 doc.first += distance;
4490 doc.sel = new Selection(map(doc.sel.ranges, function(range) {
4491 return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
4492 Pos(range.head.line + distance, range.head.ch));
4493 }), doc.sel.primIndex);
4494 if (doc.cm) {
4495 regChange(doc.cm, doc.first, doc.first - distance, distance);
4496 for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
4497 regLineChange(doc.cm, l, "gutter");
4498 }
4499 }
4500
4501 // More lower-level change function, handling only a single document
4502 // (not linked ones).

Callers 1

makeChangeSingleDocFunction · 0.85

Calls 3

mapFunction · 0.85
regChangeFunction · 0.85
regLineChangeFunction · 0.85

Tested by

no test coverage detected