Skip to content

Commit

Permalink
Move check for BuildError into rescue block to avoid loading rubygems
Browse files Browse the repository at this point in the history
  • Loading branch information
ssgelm committed Jan 9, 2017
1 parent 40b3574 commit 004df11
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions autoload/commandt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,6 @@ augroup END

ruby << EOF
# require Ruby files
EXCEPTIONS = [LoadError]
begin
require 'rubygems/ext'
EXCEPTIONS << Gem::Ext::BuildError if defined?(Gem::Ext::BuildError)
rescue LoadError
end

begin
require 'command-t'

Expand All @@ -174,17 +167,23 @@ ruby << EOF
else
$command_t = CommandT::Stub.new
end
rescue *EXCEPTIONS
load_path_modified = false
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
lib = "#{path}/ruby"
if !$LOAD_PATH.include?(lib) && File.exist?(lib)
$LOAD_PATH << lib
load_path_modified = true
rescue Exception => e
EXCEPTIONS = [LoadError]
EXCEPTIONS << Gem::Ext::BuildError if defined?(Gem::Ext::BuildError)
if EXCEPTIONS.include? e.class
load_path_modified = false
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
lib = "#{path}/ruby"
if !$LOAD_PATH.include?(lib) && File.exist?(lib)
$LOAD_PATH << lib
load_path_modified = true
end
end
end
retry if load_path_modified
retry if load_path_modified

$command_t = CommandT::Stub.new
$command_t = CommandT::Stub.new
else
raise e
end
end
EOF

0 comments on commit 004df11

Please sign in to comment.