diff options
author | Sutou Kouhei <kou@clear-code.com> | 2019-05-27 06:23:47 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-05-27 06:32:52 +0900 |
commit | 29c16b30ce7655bf34ac59b1327ab13f83dc7970 (patch) | |
tree | 5a6077526947335540c83b2861d7c96224badfe5 /lib/irb/ext/save-history.rb | |
parent | 2c91c5b329796a0c7f3cda0296d7c6d6cd6aa8c6 (diff) |
Add support for history with Reline backend
Diffstat (limited to 'lib/irb/ext/save-history.rb')
-rw-r--r-- | lib/irb/ext/save-history.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb index ab64cf543d..8ee5d269e6 100644 --- a/lib/irb/ext/save-history.rb +++ b/lib/irb/ext/save-history.rb @@ -58,8 +58,6 @@ module IRB end module HistorySavingAbility # :nodoc: - include Readline - def HistorySavingAbility.extended(obj) IRB.conf[:AT_EXIT].push proc{obj.save_history} obj.load_history @@ -67,18 +65,22 @@ module IRB end def load_history + return unless self.class.const_defined?(:HISTORY) + history = self.class::HISTORY if history_file = IRB.conf[:HISTORY_FILE] history_file = File.expand_path(history_file) end history_file = IRB.rc_file("_history") unless history_file if File.exist?(history_file) open(history_file) do |f| - f.each {|l| HISTORY << l.chomp} + f.each {|l| history << l.chomp} end end end def save_history + return unless self.class.const_defined?(:HISTORY) + history = self.class::HISTORY if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0 if history_file = IRB.conf[:HISTORY_FILE] history_file = File.expand_path(history_file) @@ -96,7 +98,7 @@ module IRB end open(history_file, 'w', 0600 ) do |f| - hist = HISTORY.to_a + hist = history.to_a f.puts(hist[-num..-1] || hist) end end |