| 8985 | } |
| 8986 | |
| 8987 | function byParagraph(cm, pos, dir) { |
| 8988 | var no = pos.line, line = cm.getLine(no); |
| 8989 | var sawText = /\S/.test(dir < 0 ? line.slice(0, pos.ch) : line.slice(pos.ch)); |
| 8990 | var fst = cm.firstLine(), lst = cm.lastLine(); |
| 8991 | for (;;) { |
| 8992 | no += dir; |
| 8993 | if (no < fst || no > lst) |
| 8994 | return cm.clipPos(Pos(no - dir, dir < 0 ? 0 : null)); |
| 8995 | line = cm.getLine(no); |
| 8996 | var hasText = /\S/.test(line); |
| 8997 | if (hasText) sawText = true; |
| 8998 | else if (sawText) return Pos(no, 0); |
| 8999 | } |
| 9000 | } |
| 9001 | |
| 9002 | function bySentence(cm, pos, dir) { |
| 9003 | var line = pos.line, ch = pos.ch; |