repl: fix tab completion for defined commands
PR-URL: https://github.com/nodejs/node/pull/7364 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
a28d3733ce
commit
9d56c4079a
@ -721,11 +721,11 @@ REPLServer.prototype.complete = function(line, callback) {
|
|||||||
|
|
||||||
// REPL commands (e.g. ".break").
|
// REPL commands (e.g. ".break").
|
||||||
var match = null;
|
var match = null;
|
||||||
match = line.match(/^\s*(\.\w*)$/);
|
match = line.match(/^\s*\.(\w*)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
completionGroups.push(Object.keys(this.commands));
|
completionGroups.push(Object.keys(this.commands));
|
||||||
completeOn = match[1];
|
completeOn = match[1];
|
||||||
if (match[1].length > 1) {
|
if (match[1].length) {
|
||||||
filter = match[1];
|
filter = match[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,3 +260,10 @@ putIn.run(['.clear']);
|
|||||||
testMe.complete('var log = console.lo', common.mustCall((error, data) => {
|
testMe.complete('var log = console.lo', common.mustCall((error, data) => {
|
||||||
assert.deepStrictEqual(data, [['console.log'], 'console.lo']);
|
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']);
|
||||||
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user