diff --git a/src/assets/plugins/codemirror/addon/hint/anyword-hint.js b/src/assets/plugins/codemirror/addon/hint/anyword-hint.js index d27a9ec..df3a97e 100644 --- a/src/assets/plugins/codemirror/addon/hint/anyword-hint.js +++ b/src/assets/plugins/codemirror/addon/hint/anyword-hint.js @@ -27,7 +27,9 @@ var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir; for (; line != endLine; line += dir) { var text = editor.getLine(line), m; - while (m = re.exec(text)) { + while (m = re.exec(text)) { + // fix + if (!curWord) continue;; if (line == cur.line && m[0] === curWord) continue; if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) { seen[m[0]] = true; diff --git a/src/assets/plugins/codemirror/addon/hint/javascript-hint.js b/src/assets/plugins/codemirror/addon/hint/javascript-hint.js index 7f78e66..2c927a0 100644 --- a/src/assets/plugins/codemirror/addon/hint/javascript-hint.js +++ b/src/assets/plugins/codemirror/addon/hint/javascript-hint.js @@ -67,8 +67,8 @@ }) } // add specialVars - var specialVars = localStorage['specialVars'].split(',') - specialVars.forEach(s => { + var specialVars = localStorage['specialVars'] + if(specialVars) specialVars.split(',').forEach(s => { if (s.toUpperCase().slice(2, token.string.length + 2) == token.string.toUpperCase()) hints.push(s) }) } @@ -123,7 +123,8 @@ // builtInFns and builtInObjs var builtInFns = ["Infinity", "NaN", "undefined", "globalThis", "eval", "isFinite", "isNaN", "parseFloat", "parseInt", "decodeURI", "decodeURIComponent", - "encodeURI", "encodeURIComponent", "escape", "unescape", "RegExp", "Promise", "Generator", "GeneratorFunction", "AsyncFunction", "arguments", "require"] + "encodeURI", "encodeURIComponent", "escape", "unescape", "RegExp", "Promise", "Generator", "GeneratorFunction", "AsyncFunction", "arguments", "require", + "console.log", "console.error"] var builtInObjs = { Object: Object, Function: Function, @@ -140,7 +141,6 @@ JSON: JSON, String: String, Array: Array, - console: { log: () => { }, error: () => { }} } function forAllProps(obj, callback) { @@ -162,7 +162,7 @@ function maybeAdd(str) { // fix 2 if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) { - if(token.string != str) found.push(str); + found.push(str); } } function gatherCompletions(obj) { diff --git a/src/assets/plugins/codemirror/addon/hint/show-hint.js b/src/assets/plugins/codemirror/addon/hint/show-hint.js index 513f9eb..5760f8a 100644 --- a/src/assets/plugins/codemirror/addon/hint/show-hint.js +++ b/src/assets/plugins/codemirror/addon/hint/show-hint.js @@ -291,7 +291,7 @@ menuSize: function() { return widget.screenAmount(); }, length: completions.length, close: function() { completion.close(); }, - pick: function() { widget.pick(); }, + pick: function() { window.editor.off("change", showHint); widget.pick(); window.editor.on("change", showHint);}, data: data })); @@ -320,7 +320,11 @@ var t = getHintElement(hints, e.target || e.srcElement); if (t && t.hintId != null) { widget.changeActive(t.hintId); - if (completion.options.completeOnSingleClick) widget.pick(); + if (completion.options.completeOnSingleClick) { + window.editor.off("change", showHint); + widget.pick(); + window.editor.on("change", showHint); + } } }); @@ -450,7 +454,7 @@ for (var i = 0; i < options.words.length; i++) { var word = options.words[i]; if (word.slice(0, tokenstring.length) == tokenstring) - if(word != tokenstring && !found.includes(word)) found.push(word); + if(!found.includes(word)) found.push(word); } if (!term) { if (!tokenstring) return { list: {} } @@ -463,8 +467,8 @@ }) } // add specialVars - var specialVars = localStorage['specialVars'].split(',') - specialVars.forEach(s => { + var specialVars = localStorage['specialVars'] + if(specialVars) specialVars.split(',').forEach(s => { if (s.toUpperCase().slice(2, tokenstring.length + 2) == tokenstring.toUpperCase()) found.push(s) }) }