GeezerVison is showing github.com — readline,repl: skip history entries identical to the current line · nodejs/node@cecd256
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/readline.js +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -702,7 +702,8 @@ Interface.prototype._historyNext = function() { |
702 | 702 | const search = this[kSubstringSearch] || ''; |
703 | 703 | let index = this.historyIndex - 1; |
704 | 704 | while (index >= 0 && |
705 | | - !this.history[index].startsWith(search)) { |
| 705 | + (!this.history[index].startsWith(search) || |
| 706 | + this.line === this.history[index])) { |
706 | 707 | index--; |
707 | 708 | } |
708 | 709 | if (index === -1) { |
@@ -721,10 +722,13 @@ Interface.prototype._historyPrev = function() { |
721 | 722 | const search = this[kSubstringSearch] || ''; |
722 | 723 | let index = this.historyIndex + 1; |
723 | 724 | while (index < this.history.length && |
724 | | - !this.history[index].startsWith(search)) { |
| 725 | + (!this.history[index].startsWith(search) || |
| 726 | + this.line === this.history[index])) { |
725 | 727 | index++; |
726 | 728 | } |
727 | 729 | if (index === this.history.length) { |
| 730 | + // TODO(BridgeAR): Change this to: |
| 731 | + // this.line = search; |
728 | 732 | return; |
729 | 733 | } else { |
730 | 734 | this.line = this.history[index]; |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-repl-history-navigation.js -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -138,11 +138,7 @@ const tests = [ |
138 | 138 | // UP - skipping const foo = true |
139 | 139 | '\x1B[1G', '\x1B[0J', |
140 | 140 | '> 555 + 909', '\x1B[12G', |
141 | | - // UP - matching the identical history entry again. |
142 | | - '\x1B[1G', '\x1B[0J', |
143 | | - '> 555 + 909', |
144 | 141 | // UP, UP, ENTER. UPs at the end of the history have no effect. |
145 | | - '\x1B[12G', |
146 | 142 | '\r\n', |
147 | 143 | '1464\n', |
148 | 144 | '\x1B[1G', '\x1B[0J', |
|