From 95d0ca534b5dd948005a29f7e3aab46ef63a87cd Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Sun, 2 Feb 2014 17:36:06 -0800 Subject: [PATCH] Don't assume Readline is loaded in auto_resize --- lib/pry/pry_class.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 7065effa..cf284b89 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -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!)