Skip to content

Commit c8e9adb

Browse files
princejwesleyMyles Borins
authored and
Myles Borins
committedJul 14, 2016
repl: fix tab completion for defined commands
PR-URL: #7364 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 71ef71c commit c8e9adb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
 

‎lib/repl.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,11 @@ REPLServer.prototype.complete = function(line, callback) {
659659

660660
// REPL commands (e.g. ".break").
661661
var match = null;
662-
match = line.match(/^\s*(\.\w*)$/);
662+
match = line.match(/^\s*\.(\w*)$/);
663663
if (match) {
664664
completionGroups.push(Object.keys(this.commands));
665665
completeOn = match[1];
666-
if (match[1].length > 1) {
666+
if (match[1].length) {
667667
filter = match[1];
668668
}
669669

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

+7
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,10 @@ putIn.run(['var obj = {1:"a","1a":"b",a:"b"};']);
306306
testMe.complete('obj.', common.mustCall(function(error, data) {
307307
assert.deepEqual(data, obj_elements);
308308
}));
309+
310+
// tab completion for defined commands
311+
putIn.run(['.clear']);
312+
313+
testMe.complete('.b', common.mustCall((error, data) => {
314+
assert.deepStrictEqual(data, [['break'], 'b']);
315+
}));

0 commit comments

Comments
 (0)
Please sign in to comment.