File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ def concat(*val)
29
29
end
30
30
31
31
def push ( *val )
32
+ # If history_size is zero, all histories are dropped.
33
+ return self if @config . history_size . zero?
32
34
diff = size + val . size - @config . history_size
33
35
if diff > 0
34
36
if diff <= size
@@ -43,6 +45,8 @@ def push(*val)
43
45
end
44
46
45
47
def <<( val )
48
+ # If history_size is zero, all histories are dropped.
49
+ return self if @config . history_size . zero?
46
50
shift if size + 1 > @config . history_size
47
51
super ( String . new ( val , encoding : Reline . encoding_system_needs ) )
48
52
end
Original file line number Diff line number Diff line change @@ -242,6 +242,16 @@ def test_delete_at__out_of_range
242
242
end
243
243
end
244
244
245
+ def test_history_size_zero
246
+ history = history_new ( history_size : 0 )
247
+ assert_equal 0 , history . size
248
+ history << 'aa'
249
+ history << 'bb'
250
+ assert_equal 0 , history . size
251
+ history . push ( *%w{ aa bb cc } )
252
+ assert_equal 0 , history . size
253
+ end
254
+
245
255
private
246
256
247
257
def history_new ( history_size : 10 )
You can’t perform that action at this time.
0 commit comments