From: Maciej MaƂecki Date: Mon, 11 Nov 2013 23:03:29 +0000 (+0100) Subject: repl: do not insert duplicates into completions X-Git-Tag: v0.10.22~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=568072ceae5566c4e3e14cef077538d2f454ee33;p=platform%2Fupstream%2Fnodejs.git 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. --- 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(['};']);