(pos)
| 1438 | |
| 1439 | function clipLine(n) {return Math.max(0, Math.min(n, doc.size-1));} |
| 1440 | function clipPos(pos) { |
| 1441 | if (pos.line < 0) return {line: 0, ch: 0}; |
| 1442 | if (pos.line >= doc.size) return {line: doc.size-1, ch: getLine(doc.size-1).text.length}; |
| 1443 | var ch = pos.ch, linelen = getLine(pos.line).text.length; |
| 1444 | if (ch == null || ch > linelen) return {line: pos.line, ch: linelen}; |
| 1445 | else if (ch < 0) return {line: pos.line, ch: 0}; |
| 1446 | else return pos; |
| 1447 | } |
| 1448 | |
| 1449 | function findPosH(dir, unit) { |
| 1450 | var end = sel.inverted ? sel.from : sel.to, line = end.line, ch = end.ch; |
no test coverage detected