MCPcopy Index your code
hub / github.com/csev/py4e / findWordAt

Function findWordAt

tools/pythonauto/static/codemirror/codemirror.js:2883–2895  ·  view source on GitHub ↗
(line, pos)

Source from the content-addressed store, hash-verified

2881 }
2882
2883 function findWordAt(line, pos) {
2884 var start = pos.ch, end = pos.ch;
2885 if (line) {
2886 if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
2887 var startChar = line.charAt(start);
2888 var check = isWordChar(startChar) ? isWordChar
2889 : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
2890 : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
2891 while (start > 0 && check(line.charAt(start - 1))) --start;
2892 while (end < line.length && check(line.charAt(end))) ++end;
2893 }
2894 return {from: Pos(pos.line, start), to: Pos(pos.line, end)};
2895 }
2896
2897 function selectLine(cm, line) {
2898 extendSelection(cm.doc, Pos(line, 0), clipPos(cm.doc, Pos(line + 1, 0)));

Callers 3

registerEventHandlersFunction · 0.70
onMouseDownFunction · 0.70
doSelectFunction · 0.70

Calls 2

PosFunction · 0.85
isWordCharFunction · 0.70

Tested by

no test coverage detected