MCPcopy Create free account
hub / github.com/breck7/scroll / adjustForChange

Function adjustForChange

external/.scrollLibs.js:6401–6415  ·  view source on GitHub ↗
(pos, change)

Source from the content-addressed store, hash-verified

6399 // Adjust a position to refer to the post-change position of the
6400 // same text, or the end of the change if the change covers it.
6401 function adjustForChange(pos, change) {
6402 if (cmp(pos, change.from) < 0) {
6403 return pos
6404 }
6405 if (cmp(pos, change.to) <= 0) {
6406 return changeEnd(change)
6407 }
6408
6409 var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1,
6410 ch = pos.ch
6411 if (pos.line == change.to.line) {
6412 ch += changeEnd(change).ch - change.to.ch
6413 }
6414 return Pos(line, ch)
6415 }
6416
6417 function computeSelAfterChange(doc, change) {
6418 var out = []

Callers 1

computeSelAfterChangeFunction · 0.85

Calls 3

cmpFunction · 0.85
changeEndFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected