Browse Source

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.
v0.10.22-release
Maciej Małecki 11 years ago
committed by Nathan Rajlich
parent
commit
568072ceae
  1. 2
      lib/repl.js
  2. 3
      test/simple/test-repl-tab-complete.js

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

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

Loading…
Cancel
Save