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.
pull/24998/head
Maciej Małecki 2013-11-12 00:03:29 +01:00 committed by Nathan Rajlich
parent 2010985354
commit 568072ceae
2 changed files with 4 additions and 1 deletions

View File

@ -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;
}

View File

@ -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(['};']);