diff options
author | aycabta <aycabta@gmail.com> | 2019-05-29 05:58:33 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-29 05:58:33 +0900 |
commit | c67934b1c3b40dda5f170b032423e520511c68dd (patch) | |
tree | a54f58476dc026d5f83899ab38fdb7002cd13c5b /lib/reline.rb | |
parent | 3b7862c8e88cd7838a53ec083ac5733386400956 (diff) |
Remove extra items because Reline::HISTORY is a sized queue
Diffstat (limited to 'lib/reline.rb')
-rw-r--r-- | lib/reline.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/reline.rb b/lib/reline.rb index df2b620448..8e7d4ff016 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -45,9 +45,23 @@ module Reline super(index, String.new(val, encoding: Encoding::default_external)) end + def concat(*val) + val.each do |v| + push(*v) + end + end + def push(*val) diff = size + val.size - @@config.history_size - shift(diff) if diff > 0 + if diff > 0 + if diff <= size + shift(diff) + else + diff -= size + clear + val.shift(diff) + end + end super(*(val.map{ |v| String.new(v, encoding: Encoding::default_external) })) end |