GeezerVison is showing github.com — repl: fix tab completion for defined commands · nodejs/node@e9585d2
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 |
|---|
@@ -659,11 +659,11 @@ REPLServer.prototype.complete = function(line, callback) { |
659 | 659 |
|
660 | 660 | // REPL commands (e.g. ".break"). |
661 | 661 | var match = null; |
662 | | - match = line.match(/^\s*(\.\w*)$/); |
| 662 | + match = line.match(/^\s*\.(\w*)$/); |
663 | 663 | if (match) { |
664 | 664 | completionGroups.push(Object.keys(this.commands)); |
665 | 665 | completeOn = match[1]; |
666 | | - if (match[1].length > 1) { |
| 666 | + if (match[1].length) { |
667 | 667 | filter = match[1]; |
668 | 668 | } |
669 | 669 |
|
|
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 |
|---|
@@ -306,3 +306,10 @@ putIn.run(['var obj = {1:"a","1a":"b",a:"b"};']); |
306 | 306 | testMe.complete('obj.', common.mustCall(function(error, data) { |
307 | 307 | assert.deepEqual(data, obj_elements); |
308 | 308 | })); |
| 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 | +})); |