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 Myles Borins committed Jul 14, 2016
1 parent 71ef71c commit c8e9adb
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 @@ -659,11 +659,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 @@ -306,3 +306,10 @@ putIn.run(['var obj = {1:"a","1a":"b",a:"b"};']);
testMe.complete('obj.', common.mustCall(function(error, data) {
assert.deepEqual(data, obj_elements);
}));

// tab completion for defined commands
putIn.run(['.clear']);

testMe.complete('.b', common.mustCall((error, data) => {
assert.deepStrictEqual(data, [['break'], 'b']);
}));

0 comments on commit c8e9adb

Please sign in to comment.