diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-29 13:09:45 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-01-10 09:11:50 +0100 |
commit | b52bf605187d65be272a0ab8fb7f5623d8934f18 (patch) | |
tree | 9e4c38e36255f31dbaad7968bf8b55b73283d6e7 /lib/readline.js | |
parent | d449c505f3413843b60caf46d5bc3ef17d711830 (diff) | |
download | node-new-b52bf605187d65be272a0ab8fb7f5623d8934f18.tar.gz |
readline,repl: improve history up/previous
Reaching the history end caused the last entry to be persistent.
That way there's no actualy feedback to the user that the history
end is reached. Instead, visualize the original input line and keep
the history index at the history end in case the user wants to go
back again.
PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/readline.js b/lib/readline.js index b7b2651aec..5f3aeedd4e 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -718,7 +718,7 @@ Interface.prototype._historyNext = function() { }; Interface.prototype._historyPrev = function() { - if (this.historyIndex < this.history.length) { + if (this.historyIndex < this.history.length && this.history.length) { const search = this[kSubstringSearch] || ''; let index = this.historyIndex + 1; while (index < this.history.length && @@ -727,9 +727,7 @@ Interface.prototype._historyPrev = function() { index++; } if (index === this.history.length) { - // TODO(BridgeAR): Change this to: - // this.line = search; - return; + this.line = search; } else { this.line = this.history[index]; } |