Don't assume Readline is loaded in auto_resize

This commit is contained in:
Ryan Fitzgerald 2014-02-02 17:36:06 -08:00
parent bfe70aa165
commit 95d0ca534b
1 changed files with 10 additions and 3 deletions

View File

@ -233,15 +233,22 @@ class Pry
end
def self.auto_resize!
ver = Readline::VERSION
if ver[/edit/i]
Pry.config.input # by default, load Readline
if !defined?(Readline) || Pry.config.input != Readline
warn "Sorry, you must be using Readline for Pry.auto_resize! to work."
return
end
if Readline::VERSION =~ /edit/i
warn <<-EOT
Readline version #{ver} detected - will not auto_resize! correctly.
Readline version #{Readline::VERSION} detected - will not auto_resize! correctly.
For the fix, use GNU Readline instead:
https://github.com/guard/guard/wiki/Add-proper-Readline-support-to-Ruby-on-Mac-OS-X
EOT
return
end
trap :WINCH do
begin
Readline.set_screen_size(*Terminal.size!)