(doc, pos)
| 3769 | |
| 3770 | // Find the word at the given position (as returned by coordsChar). |
| 3771 | function findWordAt(doc, pos) { |
| 3772 | var line = getLine(doc, pos.line).text; |
| 3773 | var start = pos.ch, end = pos.ch; |
| 3774 | if (line) { |
| 3775 | if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; |
| 3776 | var startChar = line.charAt(start); |
| 3777 | var check = isWordChar(startChar) ? isWordChar |
| 3778 | : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} |
| 3779 | : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; |
| 3780 | while (start > 0 && check(line.charAt(start - 1))) --start; |
| 3781 | while (end < line.length && check(line.charAt(end))) ++end; |
| 3782 | } |
| 3783 | return new Range(Pos(pos.line, start), Pos(pos.line, end)); |
| 3784 | } |
| 3785 | |
| 3786 | // EDITOR METHODS |
| 3787 |
no test coverage detected