summaryrefslogtreecommitdiff
path: root/lib/reline.rb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-05-29 05:58:33 +0900
committeraycabta <aycabta@gmail.com>2019-05-29 05:58:33 +0900
commitc67934b1c3b40dda5f170b032423e520511c68dd (patch)
treea54f58476dc026d5f83899ab38fdb7002cd13c5b /lib/reline.rb
parent3b7862c8e88cd7838a53ec083ac5733386400956 (diff)
Remove extra items because Reline::HISTORY is a sized queue
Diffstat (limited to 'lib/reline.rb')
-rw-r--r--lib/reline.rb16
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