From 568072ceae5566c4e3e14cef077538d2f454ee33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Tue, 12 Nov 2013 00:03:29 +0100 Subject: repl: do not insert duplicates into completions Fix invalid `hasOwnProperty` function usage. For example, before in the REPL: ``` > Ar Array Array ArrayBuffer ``` Now: ``` > Ar Array ArrayBuffer ``` Fixes #6255. Closes #6498. --- lib/repl.js | 2 +- test/simple/test-repl-tab-complete.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/repl.js b/lib/repl.js index c726065e3..61855f9f4 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -641,7 +641,7 @@ REPLServer.prototype.complete = function(line, callback) { group.sort(); for (var j = 0; j < group.length; j++) { c = group[j]; - if (!hasOwnProperty(c)) { + if (!hasOwnProperty(uniq, c)) { completions.push(c); uniq[c] = true; } diff --git a/test/simple/test-repl-tab-complete.js b/test/simple/test-repl-tab-complete.js index 591cd32e9..684063831 100644 --- a/test/simple/test-repl-tab-complete.js +++ b/test/simple/test-repl-tab-complete.js @@ -55,6 +55,9 @@ putIn.run([ testMe.complete('inner.o', function(error, data) { assert.deepEqual(data, doesNotBreak); }); +testMe.complete('console.lo', function(error, data) { + assert.deepEqual(data, [['console.log'], 'console.lo']); +}); // Tab Complete will return globaly scoped variables putIn.run(['};']); -- cgit v1.2.1