(doc, change, hint)
| 2058 | |
| 2059 | // Hint can be null|"end"|"start"|"around"|{anchor,head} |
| 2060 | function computeSelAfterChange(doc, change, hint) { |
| 2061 | if (hint && typeof hint == "object") // Assumed to be {anchor, head} object |
| 2062 | return {anchor: clipPostChange(doc, change, hint.anchor), |
| 2063 | head: clipPostChange(doc, change, hint.head)}; |
| 2064 | |
| 2065 | if (hint == "start") return {anchor: change.from, head: change.from}; |
| 2066 | |
| 2067 | var end = changeEnd(change); |
| 2068 | if (hint == "around") return {anchor: change.from, head: end}; |
| 2069 | if (hint == "end") return {anchor: end, head: end}; |
| 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 | |
| 2083 | function filterChange(doc, change) { |
| 2084 | var obj = { |
no test coverage detected