summaryrefslogtreecommitdiff
path: root/lib/internal/repl.js
diff options
context:
space:
mode:
authorJeremiah Senkpiel <fishrock123@rocketmail.com>2015-10-06 23:01:28 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2015-10-19 11:53:54 -0400
commit73b7e052c04c25887b1aba4542d30a37e39fa60a (patch)
tree856c73bac290aaf2146772e0e41cae8358c7c1e7 /lib/internal/repl.js
parent286ef1daca1c1f3e3363ee162fb97fb823632352 (diff)
downloadandroid-node-v8-73b7e052c04c25887b1aba4542d30a37e39fa60a.tar.gz
android-node-v8-73b7e052c04c25887b1aba4542d30a37e39fa60a.tar.bz2
android-node-v8-73b7e052c04c25887b1aba4542d30a37e39fa60a.zip
repl: limit persistent history correctly on load
Previously the wrong end of the history was limited on load. PR-URL: https://github.com/nodejs/node/pull/2356 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'lib/internal/repl.js')
-rw-r--r--lib/internal/repl.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/internal/repl.js b/lib/internal/repl.js
index c1beb85cef..0318a36098 100644
--- a/lib/internal/repl.js
+++ b/lib/internal/repl.js
@@ -110,7 +110,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
}
if (data) {
- repl.history = data.split(/[\n\r]+/).slice(-repl.historySize);
+ repl.history = data.split(/[\n\r]+/, repl.historySize);
} else if (oldHistoryPath) {
// Grab data from the older pre-v3.0 JSON NODE_REPL_HISTORY_FILE format.
repl._writeToOutput(
@@ -123,7 +123,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
if (!Array.isArray(repl.history)) {
throw new Error('Expected array, got ' + typeof repl.history);
}
- repl.history = repl.history.slice(-repl.historySize);
+ repl.history = repl.history.slice(0, repl.historySize);
} catch (err) {
if (err.code !== 'ENOENT') {
return ready(