diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/irb/context.rb | 14 | ||||
| -rw-r--r-- | lib/irb/init.rb | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/irb/context.rb b/lib/irb/context.rb index 668a823f5c..505bed80a1 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -176,11 +176,17 @@ module IRB private def build_completor completor_type = IRB.conf[:COMPLETOR] + + # Gem repl_type_completor is added to bundled gems in Ruby 3.4. + # Use :type as default completor only in Ruby 3.4 or later. + verbose = !!completor_type + completor_type ||= RUBY_VERSION >= '3.4' ? :type : :regexp + case completor_type when :regexp return RegexpCompletor.new when :type - completor = build_type_completor + completor = build_type_completor(verbose: verbose) return completor if completor else warn "Invalid value for IRB.conf[:COMPLETOR]: #{completor_type}" @@ -189,17 +195,17 @@ module IRB RegexpCompletor.new end - private def build_type_completor + private def build_type_completor(verbose:) if RUBY_ENGINE == 'truffleruby' # Avoid SyntaxError. truffleruby does not support endless method definition yet. - warn 'TypeCompletor is not supported on TruffleRuby yet' + warn 'TypeCompletor is not supported on TruffleRuby yet' if verbose return end begin require 'repl_type_completor' rescue LoadError => e - warn "TypeCompletor requires `gem repl_type_completor`: #{e.message}" + warn "TypeCompletor requires `gem repl_type_completor`: #{e.message}" if verbose return end diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 7dc08912ef..d474bd41d6 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -80,7 +80,7 @@ module IRB # :nodoc: @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod) @CONF[:USE_COLORIZE] = (nc = ENV['NO_COLOR']).nil? || nc.empty? @CONF[:USE_AUTOCOMPLETE] = ENV.fetch("IRB_USE_AUTOCOMPLETE", "true") != "false" - @CONF[:COMPLETOR] = ENV.fetch("IRB_COMPLETOR", "regexp").to_sym + @CONF[:COMPLETOR] = ENV["IRB_COMPLETOR"]&.to_sym @CONF[:INSPECT_MODE] = true @CONF[:USE_TRACER] = false @CONF[:USE_LOADER] = false |
