(pos, linelen)
| 1024 | return clipToLen(pos, getLine(doc, pos.line).text.length); |
| 1025 | } |
| 1026 | function clipToLen(pos, linelen) { |
| 1027 | var ch = pos.ch; |
| 1028 | if (ch == null || ch > linelen) return Pos(pos.line, linelen); |
| 1029 | else if (ch < 0) return Pos(pos.line, 0); |
| 1030 | else return pos; |
| 1031 | } |
| 1032 | function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;} |
| 1033 | function clipPosArray(doc, array) { |
| 1034 | for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]); |