1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

rescuing IndexError exception in update_input_history method as a workaround for libedit but in ruby 1.8.7

This commit is contained in:
John Mair 2011-08-11 23:35:04 +12:00
parent d326f2e57a
commit 0c1df619f3

View file

@ -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
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