(pos)
| 1238 | |
| 1239 | function clipLine(n) {return Math.max(0, Math.min(n, doc.size-1));} |
| 1240 | function clipPos(pos) { |
| 1241 | if (pos.line < 0) return {line: 0, ch: 0}; |
| 1242 | if (pos.line >= doc.size) return {line: doc.size-1, ch: getLine(doc.size-1).text.length}; |
| 1243 | var ch = pos.ch, linelen = getLine(pos.line).text.length; |
| 1244 | if (ch == null || ch > linelen) return {line: pos.line, ch: linelen}; |
| 1245 | else if (ch < 0) return {line: pos.line, ch: 0}; |
| 1246 | else return pos; |
| 1247 | } |
| 1248 | |
| 1249 | function findPosH(dir, unit) { |
| 1250 | var end = sel.inverted ? sel.from : sel.to, line = end.line, ch = end.ch; |
no test coverage detected