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