Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ca95a84

Browse filesBrowse 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
Copy full SHA for ca95a84

File tree

Expand file treeCollapse file tree

2 files changed

+9
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-2
lines changed
Open diff view settings
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+2-2Lines 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
var match = 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

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-repl-tab-complete.js
+7Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.