PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.5
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.5
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / lib / codemirror / addon / hint / anyword-hint.js

anyword-hint.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.5, at assets/lib/codemirror/addon/hint/anyword-hint.js

35 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function() {
2 "use strict";
3
4 var WORD = /[\w$]+/, RANGE = 500;
5
6 CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
7 var word = options && options.word || WORD;
8 var range = options && options.range || RANGE;
9 var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
10 var start = cur.ch, end = start;
11 while (end < curLine.length && word.test(curLine.charAt(end))) ++end;
12 while (start && word.test(curLine.charAt(start - 1))) --start;
13 var curWord = start != end && curLine.slice(start, end);
14
15 var list = [], seen = {};
16 function scan(dir) {
17 var line = cur.line, end = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
18 for (; line != end; line += dir) {
19 var text = editor.getLine(line), m;
20 var re = new RegExp(word.source, "g");
21 while (m = re.exec(text)) {
22 if (line == cur.line && m[0] === curWord) continue;
23 if ((!curWord || m[0].indexOf(curWord) == 0) && !seen.hasOwnProperty(m[0])) {
24 seen[m[0]] = true;
25 list.push(m[0]);
26 }
27 }
28 }
29 }
30 scan(-1);
31 scan(1);
32 return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
33 });
34 })();
35