(pos, linelen)
| 2097 | return clipToLen(pos, getLine(doc, pos.line).text.length); |
| 2098 | } |
| 2099 | function clipToLen(pos, linelen) { |
| 2100 | var ch = pos.ch; |
| 2101 | if (ch == null || ch > linelen) return Pos(pos.line, linelen); |
| 2102 | else if (ch < 0) return Pos(pos.line, 0); |
| 2103 | else return pos; |
| 2104 | } |
| 2105 | function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;} |
| 2106 | function clipPosArray(doc, array) { |
| 2107 | for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]); |