MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / adjustPos

Function adjustPos

static/js/codemirror/codemirror.js:2072–2079  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

2070
2071 // hint is null, leave the selection alone as much as possible
2072 var adjustPos = function(pos) {
2073 if (posLess(pos, change.from)) return pos;
2074 if (!posLess(change.to, pos)) return end;
2075
2076 var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
2077 if (pos.line == change.to.line) ch += end.ch - change.to.ch;
2078 return Pos(line, ch);
2079 };
2080 return {anchor: adjustPos(doc.sel.anchor), head: adjustPos(doc.sel.head)};
2081 }
2082

Callers 1

computeSelAfterChangeFunction · 0.85

Calls 2

posLessFunction · 0.85
PosFunction · 0.85

Tested by

no test coverage detected