(code, from, to)
| 778 | } |
| 779 | |
| 780 | function replaceRange(code, from, to) { |
| 781 | from = clipPos(from); |
| 782 | if (!to) to = from; else to = clipPos(to); |
| 783 | code = splitLines(code); |
| 784 | function adjustPos(pos) { |
| 785 | if (posLess(pos, from)) return pos; |
| 786 | if (!posLess(to, pos)) return end; |
| 787 | var line = pos.line + code.length - (to.line - from.line) - 1; |
| 788 | var ch = pos.ch; |
| 789 | if (pos.line == to.line) |
| 790 | ch += code[code.length-1].length - (to.ch - (to.line == from.line ? from.ch : 0)); |
| 791 | return {line: line, ch: ch}; |
| 792 | } |
| 793 | var end; |
| 794 | replaceRange1(code, from, to, function(end1) { |
| 795 | end = end1; |
| 796 | return {from: adjustPos(sel.from), to: adjustPos(sel.to)}; |
| 797 | }); |
| 798 | return end; |
| 799 | } |
| 800 | function replaceSelection(code, collapse) { |
| 801 | replaceRange1(splitLines(code), sel.from, sel.to, function(end) { |
| 802 | if (collapse == "end") return {from: end, to: end}; |
no test coverage detected