GeezerVison is showing github.com — repl: fix tab completion for defined commands · nodejs/node@ca95a84
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/repl.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -721,11 +721,11 @@ REPLServer.prototype.complete = function(line, callback) { |
721 | 721 |
|
722 | 722 | // REPL commands (e.g. ".break"). |
723 | 723 | var match = null; |
724 | | - match = line.match(/^\s*(\.\w*)$/); |
| 724 | + match = line.match(/^\s*\.(\w*)$/); |
725 | 725 | if (match) { |
726 | 726 | completionGroups.push(Object.keys(this.commands)); |
727 | 727 | completeOn = match[1]; |
728 | | - if (match[1].length > 1) { |
| 728 | + if (match[1].length) { |
729 | 729 | filter = match[1]; |
730 | 730 | } |
731 | 731 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-repl-tab-complete.js +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -260,3 +260,10 @@ putIn.run(['.clear']); |
260 | 260 | testMe.complete('var log = console.lo', common.mustCall((error, data) => { |
261 | 261 | assert.deepStrictEqual(data, [['console.log'], 'console.lo']); |
262 | 262 | })); |
| 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 | +})); |