ruby-changes:59637
From: aycabta <ko1@a...>
Date: Mon, 6 Jan 2020 21:53:42 +0900 (JST)
Subject: [ruby-changes:59637] 7392083c2f (master): Support history-size in .inputrc correctly
https://git.ruby-lang.org/ruby.git/commit/?id=7392083c2f From 7392083c2ffa2dc5449ec0aa529f4a792fb1d2b4 Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Mon, 6 Jan 2020 21:50:48 +0900 Subject: Support history-size in .inputrc correctly diff --git a/lib/reline/config.rb b/lib/reline/config.rb index fdc2b39..61708f9 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -184,9 +184,8 @@ class Reline::Config https://github.com/ruby/ruby/blob/trunk/lib/reline/config.rb#L184 def bind_variable(name, value) case name - when *VARIABLE_NAMES then - variable_name = :"@#{name.tr(?-, ?_)}" - instance_variable_set(variable_name, value.nil? || value == '1' || value == 'on') + when 'history-size' + @history_size = value.to_i when 'bell-style' @bell_style = case value @@ -225,6 +224,9 @@ class Reline::Config https://github.com/ruby/ruby/blob/trunk/lib/reline/config.rb#L224 end when 'keyseq-timeout' @keyseq_timeout = value.to_i + when *VARIABLE_NAMES then + variable_name = :"@#{name.tr(?-, ?_)}" + instance_variable_set(variable_name, value.nil? || value == '1' || value == 'on') end end diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb index dd5142d..14342ff 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -195,4 +195,15 @@ class Reline::Config::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_config.rb#L195 expected = { 'ef'.bytes => 'EF'.bytes, 'gh'.bytes => 'GH'.bytes } assert_equal expected, @config.key_bindings end + + def test_history_size + @config.read_lines(<<~LINES.lines) + set history-size 5000 + LINES + + assert_equal 5000, @config.instance_variable_get(:@history_size) + history = Reline::History.new(@config) + history << "a\n" + assert_equal 1, history.size + end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/