Skip to content

Commit

Permalink
Merge pull request #215 from bliof/prevent-crashes-when-rdoc-is-missing
Browse files Browse the repository at this point in the history
Prevent the completion from crashing if rdoc is missing
  • Loading branch information
aycabta authored Mar 30, 2021
2 parents ddd50e3 + a2d299c commit 204a4e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/irb/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# From Original Idea of shugo@ruby-lang.org
#

autoload :RDoc, "rdoc"

require_relative 'ruby-lex'

module IRB
Expand Down Expand Up @@ -329,13 +327,22 @@ def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace
end

PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
begin
require 'rdoc'
rescue LoadError
return
end

RDocRIDriver ||= RDoc::RI::Driver.new

if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
IRB.__send__(:easter_egg)
return
end

namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
return unless namespace

if namespace.is_a?(Array)
out = RDoc::Markup::Document.new
namespace.each do |m|
Expand Down

0 comments on commit 204a4e5

Please sign in to comment.