From 568072ceae5566c4e3e14cef077538d2f454ee33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Maciej=20Ma=C5=82ecki?= Date: Tue, 12 Nov 2013 00:03:29 +0100 Subject: [PATCH] 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 c726065..61855f9 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 591cd32..6840638 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(['};']); -- 2.7.4