(code, from, to)
| 978 | } |
| 979 | |
| 980 | function replaceRange(code, from, to) { |
| 981 | from = clipPos(from); |
| 982 | if (!to) to = from; else to = clipPos(to); |
| 983 | code = splitLines(code); |
| 984 | function adjustPos(pos) { |
| 985 | if (posLess(pos, from)) return pos; |
| 986 | if (!posLess(to, pos)) return end; |
| 987 | var line = pos.line + code.length - (to.line - from.line) - 1; |
| 988 | var ch = pos.ch; |
| 989 | if (pos.line == to.line) |
| 990 | ch += code[code.length-1].length - (to.ch - (to.line == from.line ? from.ch : 0)); |
| 991 | return {line: line, ch: ch}; |
| 992 | } |
| 993 | var end; |
| 994 | replaceRange1(code, from, to, function(end1) { |
| 995 | end = end1; |
| 996 | return {from: adjustPos(sel.from), to: adjustPos(sel.to)}; |
| 997 | }); |
| 998 | return end; |
| 999 | } |
| 1000 | function replaceSelection(code, collapse) { |
| 1001 | replaceRange1(splitLines(code), sel.from, sel.to, function(end) { |
| 1002 | if (collapse == "end") return {from: end, to: end}; |
no test coverage detected