(doc, pos)
| 2544 | |
| 2545 | function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));} |
| 2546 | function clipPos(doc, pos) { |
| 2547 | if (pos.line < doc.first) return Pos(doc.first, 0); |
| 2548 | var last = doc.first + doc.size - 1; |
| 2549 | if (pos.line > last) return Pos(last, getLine(doc, last).text.length); |
| 2550 | return clipToLen(pos, getLine(doc, pos.line).text.length); |
| 2551 | } |
| 2552 | function clipToLen(pos, linelen) { |
| 2553 | var ch = pos.ch; |
| 2554 | if (ch == null || ch > linelen) return Pos(pos.line, linelen); |
no test coverage detected