(doc, change, hint)
| 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 = { |
no test coverage detected