1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] Get rid of loading readline unnecessarily

https://github.com/ruby/irb/commit/420e7d2270
This commit is contained in:
Nobuyoshi Nakada 2020-08-12 11:21:36 +09:00 committed by aycabta
parent d32229e338
commit 6aa786b8a3
2 changed files with 9 additions and 11 deletions

View file

@ -7,7 +7,6 @@
# From Original Idea of shugo@ruby-lang.org
#
require "readline"
autoload :RDoc, "rdoc"
module IRB

View file

@ -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