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 <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • Loading branch information
princejwesley authored and Fishrock123 committed Jul 5, 2016
1 parent efce335 commit ca95a84
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 ca95a84

Please sign in to comment.