| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1e065a0 commit 6c87b59
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -632,9 +632,21 @@ Interface.prototype._tabComplete = function(lastKeypressWasTab) { | |||
| 632 | 632 | // If there is a common prefix to all matches, then apply that portion. | |
| 633 | 633 | const prefix = commonPrefix(ArrayPrototypeFilter(completions, | |
| 634 | 634 | (e) => e !== '')); | |
| 635 | - if (prefix.length > completeOn.length) { | ||
| 635 | + if (StringPrototypeStartsWith(prefix, completeOn) && | ||
| 636 | + prefix.length > completeOn.length) { | ||
| 636 | 637 | this._insertString(StringPrototypeSlice(prefix, completeOn.length)); | |
| 637 | 638 | return; | |
| 639 | + } else if (!StringPrototypeStartsWith(completeOn, prefix)) { | ||
| 640 | + this.line = StringPrototypeSlice(this.line, | ||
| 641 | + 0, | ||
| 642 | + this.cursor - completeOn.length) + | ||
| 643 | + prefix + | ||
| 644 | + StringPrototypeSlice(this.line, | ||
| 645 | + this.cursor, | ||
| 646 | + this.line.length); | ||
| 647 | + this.cursor = this.cursor - completeOn.length + prefix.length; | ||
| 648 | + this._refreshLine(); | ||
| 649 | + return; | ||
| 638 | 650 | } | |
| 639 | 651 | ||
| 640 | 652 | if (!lastKeypressWasTab) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,3 +100,39 @@ common.skipIfDumbTerminal(); | |||
| 100 | 100 | }); | |
| 101 | 101 | rli.close(); | |
| 102 | 102 | } | |
| 103 | + | ||
| 104 | + { | ||
| 105 | + let output = ''; | ||
| 106 | + class FakeInput extends EventEmitter { | ||
| 107 | + columns = 80 | ||
| 108 | + | ||
| 109 | + write = common.mustCall((data) => { | ||
| 110 | + output += data; | ||
| 111 | + }, 9) | ||
| 112 | + | ||
| 113 | + resume() {} | ||
| 114 | + pause() {} | ||
| 115 | + end() {} | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + const fi = new FakeInput(); | ||
| 119 | + const rli = new readline.Interface({ | ||
| 120 | + input: fi, | ||
| 121 | + output: fi, | ||
| 122 | + terminal: true, | ||
| 123 | + completer: common.mustCall((input, cb) => { | ||
| 124 | + cb(null, [[input[0].toUpperCase() + input.slice(1)], input]); | ||
| 125 | + }), | ||
| 126 | + }); | ||
| 127 | + | ||
| 128 | + rli.on('line', common.mustNotCall()); | ||
| 129 | + fi.emit('data', 'input'); | ||
| 130 | + queueMicrotask(() => { | ||
| 131 | + fi.emit('data', '\t'); | ||
| 132 | + queueMicrotask(() => { | ||
| 133 | + assert.match(output, /> Input/); | ||
| 134 | + output = ''; | ||
| 135 | + rli.close(); | ||
| 136 | + }); | ||
| 137 | + }); | ||
| 138 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments