diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-08-12 11:21:36 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2020-08-18 14:38:01 +0900 |
commit | 6aa786b8a3a2bd817839edde8ace54efc0681d42 (patch) | |
tree | 45d92e42649ba81d643c847740af53b10f6625a4 | |
parent | d32229e33872d3c64d21dd016ec85a6b3e605890 (diff) |
[ruby/irb] Get rid of loading readline unnecessarily
https://github.com/ruby/irb/commit/420e7d2270
-rw-r--r-- | lib/irb/completion.rb | 1 | ||||
-rw-r--r-- | lib/irb/input-method.rb | 19 |
2 files changed, 9 insertions, 11 deletions
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index 0d5420bc75..c9328e5c5a 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -7,7 +7,6 @@ # From Original Idea of [email protected] # -require "readline" autoload :RDoc, "rdoc" module IRB diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index 8f337e0eac..d2c38c18b0 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -143,11 +143,17 @@ module IRB end begin - require "readline" class ReadlineInputMethod < InputMethod - include Readline + def self.initialize_readline + require "readline" + rescue LoadError + else + include ::Readline + end + # Creates a new input method object using Readline def initialize + self.class.initialize_readline if Readline.respond_to?(:encoding_system_needs) IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false) end @@ -212,12 +218,6 @@ module IRB @stdin.external_encoding end - if Readline.respond_to?("basic_word_break_characters=") - Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS - end - Readline.completion_append_character = nil - Readline.completion_proc = IRB::InputCompletor::CompletionProc - # For debug message def inspect readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline' @@ -227,7 +227,6 @@ module IRB str end end - rescue LoadError end class ReidlineInputMethod < InputMethod @@ -251,7 +250,7 @@ module IRB Reline.completion_proc = IRB::InputCompletor::CompletionProc Reline.output_modifier_proc = if IRB.conf[:USE_COLORIZE] - proc do |output, complete:| + proc do |output, complete: | next unless IRB::Color.colorable? IRB::Color.colorize_code(output, complete: complete) end |