(doc, pos)
| 1116 | return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1)) |
| 1117 | } |
| 1118 | function clipPos(doc, pos) { |
| 1119 | if (pos.line < doc.first) { |
| 1120 | return Pos(doc.first, 0) |
| 1121 | } |
| 1122 | var last = doc.first + doc.size - 1 |
| 1123 | if (pos.line > last) { |
| 1124 | return Pos(last, getLine(doc, last).text.length) |
| 1125 | } |
| 1126 | return clipToLen(pos, getLine(doc, pos.line).text.length) |
| 1127 | } |
| 1128 | function clipToLen(pos, linelen) { |
| 1129 | var ch = pos.ch |
| 1130 | if (ch == null || ch > linelen) { |
no test coverage detected