(doc, pos)
| 3808 | |
| 3809 | // Find the word at the given position (as returned by coordsChar). |
| 3810 | function findWordAt(doc, pos) { |
| 3811 | var line = getLine(doc, pos.line).text; |
| 3812 | var start = pos.ch, end = pos.ch; |
| 3813 | if (line) { |
| 3814 | if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; |
| 3815 | var startChar = line.charAt(start); |
| 3816 | var check = isWordChar(startChar) ? isWordChar |
| 3817 | : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} |
| 3818 | : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; |
| 3819 | while (start > 0 && check(line.charAt(start - 1))) --start; |
| 3820 | while (end < line.length && check(line.charAt(end))) ++end; |
| 3821 | } |
| 3822 | return new Range(Pos(pos.line, start), Pos(pos.line, end)); |
| 3823 | } |
| 3824 | |
| 3825 | // EDITOR METHODS |
| 3826 |
no test coverage detected
searching dependent graphs…