MCPcopy Index your code
hub / github.com/csev/py4e / computeSelAfterChange

Function computeSelAfterChange

tools/pythonauto/static/codemirror/codemirror.js:2305–2326  ·  view source on GitHub ↗
(doc, change, hint)

Source from the content-addressed store, hash-verified

2303
2304 // Hint can be null|"end"|"start"|"around"|{anchor,head}
2305 function computeSelAfterChange(doc, change, hint) {
2306 if (hint && typeof hint == "object") // Assumed to be {anchor, head} object
2307 return {anchor: clipPostChange(doc, change, hint.anchor),
2308 head: clipPostChange(doc, change, hint.head)};
2309
2310 if (hint == "start") return {anchor: change.from, head: change.from};
2311
2312 var end = changeEnd(change);
2313 if (hint == "around") return {anchor: change.from, head: end};
2314 if (hint == "end") return {anchor: end, head: end};
2315
2316 // hint is null, leave the selection alone as much as possible
2317 var adjustPos = function(pos) {
2318 if (posLess(pos, change.from)) return pos;
2319 if (!posLess(change.to, pos)) return end;
2320
2321 var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
2322 if (pos.line == change.to.line) ch += end.ch - change.to.ch;
2323 return Pos(line, ch);
2324 };
2325 return {anchor: adjustPos(doc.sel.anchor), head: adjustPos(doc.sel.head)};
2326 }
2327
2328 function filterChange(doc, change, update) {
2329 var obj = {

Callers 3

makeChangeNoReadonlyFunction · 0.70
makeChangeFromHistoryFunction · 0.70
makeChangeSingleDocFunction · 0.70

Calls 2

clipPostChangeFunction · 0.85
adjustPosFunction · 0.70

Tested by

no test coverage detected