(pos, linelen)
| 1996 | return clipToLen(pos, getLine(doc, pos.line).text.length); |
| 1997 | } |
| 1998 | function clipToLen(pos, linelen) { |
| 1999 | var ch = pos.ch; |
| 2000 | if (ch == null || ch > linelen) return Pos(pos.line, linelen); |
| 2001 | else if (ch < 0) return Pos(pos.line, 0); |
| 2002 | else return pos; |
| 2003 | } |
| 2004 | function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;} |
| 2005 | function clipPosArray(doc, array) { |
| 2006 | for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]); |