diff options
author | Maciej MaĆecki <me@mmalecki.com> | 2013-11-12 00:03:29 +0100 |
---|---|---|
committer | Nathan Rajlich <nathan@tootallnate.net> | 2013-11-11 15:45:09 -0800 |
commit | 568072ceae5566c4e3e14cef077538d2f454ee33 (patch) | |
tree | 05c99fd6c0a89254b6e70a8ba36818bd8ab74045 | |
parent | 201098535443ef6588b0fd176a425fdf3213ee70 (diff) | |
download | node-568072ceae5566c4e3e14cef077538d2f454ee33.tar.gz |
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.
-rw-r--r-- | lib/repl.js | 2 | ||||
-rw-r--r-- | test/simple/test-repl-tab-complete.js | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/repl.js b/lib/repl.js index c726065e3..61855f9f4 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 591cd32e9..684063831 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(['};']); |