From 0c1df619f3f6f241f97e1418be83f4c75beb336e Mon Sep 17 00:00:00 2001 From: John Mair Date: Thu, 11 Aug 2011 23:35:04 +1200 Subject: [PATCH] rescuing IndexError exception in update_input_history method as a workaround for libedit but in ruby 1.8.7 --- lib/pry/pry_instance.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 35446e48..f75b82e4 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -342,7 +342,7 @@ class Pry # Update Pry's internal state after evalling code. # This method should not need to be invoked directly. - # @param [String] code, The code we just eval'd + # @param [String] code The code we just eval'd def update_input_history(code) # Always push to the @input_array as the @output_array is always pushed to. @input_array << code @@ -351,7 +351,11 @@ class Pry Pry.current_line += code.each_line.count end if Readline::HISTORY.size > 0 - last = Readline::HISTORY[-1].strip + begin + last = Readline::HISTORY[-1].strip + rescue IndexError + return + end prev = Readline::HISTORY.size > 1 ? Readline::HISTORY[-2].strip : '' Readline::HISTORY.pop if last && (last.empty? || last == prev) end