Skip to content

Commit 568072c

Browse files
mmaleckiTooTallNate
authored andcommitted
repl: do not insert duplicates into completions
Fix invalid `hasOwnProperty` function usage. For example, before in the REPL: ``` > Ar<Tab> Array Array ArrayBuffer ``` Now: ``` > Ar<Tab> Array ArrayBuffer ``` Fixes #6255. Closes #6498.
1 parent 2010985 commit 568072c

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

lib/repl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ REPLServer.prototype.complete = function(line, callback) {
641641
group.sort();
642642
for (var j = 0; j < group.length; j++) {
643643
c = group[j];
644-
if (!hasOwnProperty(c)) {
644+
if (!hasOwnProperty(uniq, c)) {
645645
completions.push(c);
646646
uniq[c] = true;
647647
}

test/simple/test-repl-tab-complete.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ putIn.run([
5555
testMe.complete('inner.o', function(error, data) {
5656
assert.deepEqual(data, doesNotBreak);
5757
});
58+
testMe.complete('console.lo', function(error, data) {
59+
assert.deepEqual(data, [['console.log'], 'console.lo']);
60+
});
5861

5962
// Tab Complete will return globaly scoped variables
6063
putIn.run(['};']);

0 commit comments

Comments
 (0)