Skip to content

Commit ca95a84

Browse files
princejwesleyFishrock123
authored andcommitted
repl: fix tab completion for defined commands
PR-URL: #7364 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent efce335 commit ca95a84

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎lib/repl.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,11 @@ REPLServer.prototype.complete = function(line, callback) {
721721

722722
// REPL commands (e.g. ".break").
723723
varmatch=null;
724-
match=line.match(/^\s*(\.\w*)$/);
724+
match=line.match(/^\s*\.(\w*)$/);
725725
if(match){
726726
completionGroups.push(Object.keys(this.commands));
727727
completeOn=match[1];
728-
if(match[1].length>1){
728+
if(match[1].length){
729729
filter=match[1];
730730
}
731731

‎test/parallel/test-repl-tab-complete.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,10 @@ putIn.run(['.clear']);
260260
testMe.complete('var log = console.lo',common.mustCall((error,data)=>{
261261
assert.deepStrictEqual(data,[['console.log'],'console.lo']);
262262
}));
263+
264+
// tab completion for defined commands
265+
putIn.run(['.clear']);
266+
267+
testMe.complete('.b',common.mustCall((error,data)=>{
268+
assert.deepStrictEqual(data,[['break'],'b']);
269+
}));

0 commit comments

Comments
 (0)