summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej MaƂecki <me@mmalecki.com>2013-11-12 00:03:29 +0100
committerNathan Rajlich <nathan@tootallnate.net>2013-11-11 15:45:09 -0800
commit568072ceae5566c4e3e14cef077538d2f454ee33 (patch)
tree05c99fd6c0a89254b6e70a8ba36818bd8ab74045
parent201098535443ef6588b0fd176a425fdf3213ee70 (diff)
downloadnode-new-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.js2
-rw-r--r--test/simple/test-repl-tab-complete.js3
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/repl.js b/lib/repl.js
index c726065e3f..61855f9f4e 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 591cd32e98..684063831b 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(['};']);