diff options
Diffstat (limited to 'lib/repl.js')
-rw-r--r-- | lib/repl.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/repl.js b/lib/repl.js index 420fde45eb6..763e283816b 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -611,9 +611,7 @@ REPLServer.prototype.complete = function(line, callback) { if (!expr) { // If context is instance of vm.ScriptContext // Get global vars synchronously - if (this.useGlobal || - this.context.constructor && - this.context.constructor.name === 'Context') { + if (this.useGlobal || vm.isContext(this.context)) { var contextProto = this.context; while (contextProto = Object.getPrototypeOf(contextProto)) { completionGroups.push(Object.getOwnPropertyNames(contextProto)); @@ -643,7 +641,14 @@ REPLServer.prototype.complete = function(line, callback) { if (obj != null) { if (typeof obj === 'object' || typeof obj === 'function') { - memberGroups.push(Object.getOwnPropertyNames(obj)); + try { + memberGroups.push(Object.getOwnPropertyNames(obj)); + } catch (ex) { + // Probably a Proxy object without `getOwnPropertyNames` trap. + // We simply ignore it here, as we don't want to break the + // autocompletion. Fixes the bug + // https://github.com/nodejs/io.js/issues/2119 + } } // works for non-objects try { @@ -857,7 +862,6 @@ function addStandardGlobals(completionGroups, filter) { } function defineDefaultCommands(repl) { - // TODO remove me after 0.3.x repl.defineCommand('break', { help: 'Sometimes you get stuck, this gets you out', action: function() { @@ -996,7 +1000,7 @@ function isRecoverableError(e, self) { self._inTemplateLiteral = true; return true; } - return /^(Unexpected end of input|Unexpected token :)/.test(message); + return /^(Unexpected end of input|Unexpected token)/.test(message); } return false; } |