Skip to content

Commit

Permalink
repl: fix tab completion for defined commands
Browse files Browse the repository at this point in the history
PR-URL: #7364
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information
princejwesley authored and Fishrock123 committed Jun 27, 2016
1 parent a28d373 commit 9d56c40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-repl-tab-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}));

0 comments on commit 9d56c40

Please sign in to comment.