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:
parent
d326f2e57a
commit
0c1df619f3
1 changed files with 6 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue