[前][次][番号順一覧][スレッド一覧]

ruby-changes:62615

From: Nobuyoshi <ko1@a...>
Date: Tue, 18 Aug 2020 18:57:11 +0900 (JST)
Subject: [ruby-changes:62615] 6aa786b8a3 (master): [ruby/irb] Get rid of loading readline unnecessarily

https://git.ruby-lang.org/ruby.git/commit/?id=6aa786b8a3

From 6aa786b8a3a2bd817839edde8ace54efc0681d42 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 12 Aug 2020 11:21:36 +0900
Subject: [ruby/irb] Get rid of loading readline unnecessarily

https://github.com/ruby/irb/commit/420e7d2270

diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 0d5420b..c9328e5 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -7,7 +7,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/irb/completion.rb#L7
 #       From Original Idea of shugo@r...
 #
 
-require "readline"
 autoload :RDoc, "rdoc"
 
 module IRB
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 8f337e0..d2c38c1 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -143,11 +143,17 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L143
   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 https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L218
         @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 https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L227
         str
       end
     end
-  rescue LoadError
   end
 
   class ReidlineInputMethod < InputMethod
@@ -251,7 +250,7 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L250
       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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]