summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrince J Wesley <princejohnwesley@gmail.com>2016-06-22 16:24:52 +0530
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2016-06-27 14:26:03 +0200
commit9d56c4079a05e76bb36c471dbb6967630594bd5c (patch)
tree4feedf5efaab371fe9619a882181b54f7fab4653
parenta28d3733ce4807684db64982317438d069f0cdd8 (diff)
downloadnode-new-9d56c4079a05e76bb36c471dbb6967630594bd5c.tar.gz
repl: fix tab completion for defined commands
PR-URL: https://github.com/nodejs/node/pull/7364 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
-rw-r--r--lib/repl.js4
-rw-r--r--test/parallel/test-repl-tab-complete.js7
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/repl.js b/lib/repl.js
index 01a595984d..18c81c438d 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -721,11 +721,11 @@ REPLServer.prototype.complete = function(line, callback) {
// REPL commands (e.g. ".break").
var match = null;
- match = line.match(/^\s*(\.\w*)$/);
+ match = line.match(/^\s*\.(\w*)$/);
if (match) {
completionGroups.push(Object.keys(this.commands));
completeOn = match[1];
- if (match[1].length > 1) {
+ if (match[1].length) {
filter = match[1];
}
diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js
index eb4e68ad18..d92377efeb 100644
--- a/test/parallel/test-repl-tab-complete.js
+++ b/test/parallel/test-repl-tab-complete.js
@@ -260,3 +260,10 @@ putIn.run(['.clear']);
testMe.complete('var log = console.lo', common.mustCall((error, data) => {
assert.deepStrictEqual(data, [['console.log'], 'console.lo']);
}));
+
+// tab completion for defined commands
+putIn.run(['.clear']);
+
+testMe.complete('.b', common.mustCall((error, data) => {
+ assert.deepStrictEqual(data, [['break'], 'b']);
+}));