aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/context.rb10
-rw-r--r--lib/irb/history.rb6
-rw-r--r--lib/irb/input-method.rb12
3 files changed, 6 insertions, 22 deletions
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index bf5b4c5708..18125ff6fb 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -8,7 +8,6 @@ require_relative "workspace"
require_relative "inspector"
require_relative "input-method"
require_relative "output-method"
-require_relative "history"
module IRB
# A class that wraps the current state of the irb session, including the
@@ -130,8 +129,6 @@ module IRB
else
@io = input_method
end
- self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
-
@extra_doc_dirs = IRB.conf[:EXTRA_DOC_DIRS]
@echo = IRB.conf[:ECHO]
@@ -154,13 +151,6 @@ module IRB
def save_history=(val)
IRB.conf[:SAVE_HISTORY] = val
-
- if val
- context = (IRB.conf[:MAIN_CONTEXT] || self)
- if context.io.support_history_saving? && !context.io.singleton_class.include?(HistorySavingAbility)
- context.io.extend(HistorySavingAbility)
- end
- end
end
def save_history
diff --git a/lib/irb/history.rb b/lib/irb/history.rb
index e18ff516b2..516890ac05 100644
--- a/lib/irb/history.rb
+++ b/lib/irb/history.rb
@@ -1,9 +1,7 @@
module IRB
module HistorySavingAbility # :nodoc:
- def HistorySavingAbility.extended(obj)
- IRB.conf[:AT_EXIT].push proc{obj.save_history}
- obj.load_history
- obj
+ def support_history_saving?
+ true
end
def load_history
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 4dc43abba3..245b935668 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -5,6 +5,7 @@
#
require_relative 'completion'
+require_relative "history"
require 'io/console'
require 'reline'
@@ -167,6 +168,8 @@ module IRB
include ::Readline
end
+ include HistorySavingAbility
+
# Creates a new input method object using Readline
def initialize
self.class.initialize_readline
@@ -219,10 +222,6 @@ module IRB
true
end
- def support_history_saving?
- true
- end
-
# Returns the current line number for #io.
#
# #line counts the number of times #gets is called.
@@ -250,6 +249,7 @@ module IRB
class RelineInputMethod < InputMethod
HISTORY = Reline::HISTORY
+ include HistorySavingAbility
# Creates a new input method object using Reline
def initialize
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
@@ -451,10 +451,6 @@ module IRB
str += " and #{inputrc_path}" if File.exist?(inputrc_path)
str
end
-
- def support_history_saving?
- true
- end
end
class ReidlineInputMethod < RelineInputMethod