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.
|
# Update Pry's internal state after evalling code.
|
||||||
# This method should not need to be invoked directly.
|
# 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)
|
def update_input_history(code)
|
||||||
# Always push to the @input_array as the @output_array is always pushed to.
|
# Always push to the @input_array as the @output_array is always pushed to.
|
||||||
@input_array << code
|
@input_array << code
|
||||||
|
@ -351,7 +351,11 @@ class Pry
|
||||||
Pry.current_line += code.each_line.count
|
Pry.current_line += code.each_line.count
|
||||||
end
|
end
|
||||||
if Readline::HISTORY.size > 0
|
if Readline::HISTORY.size > 0
|
||||||
|
begin
|
||||||
last = Readline::HISTORY[-1].strip
|
last = Readline::HISTORY[-1].strip
|
||||||
|
rescue IndexError
|
||||||
|
return
|
||||||
|
end
|
||||||
prev = Readline::HISTORY.size > 1 ? Readline::HISTORY[-2].strip : ''
|
prev = Readline::HISTORY.size > 1 ? Readline::HISTORY[-2].strip : ''
|
||||||
Readline::HISTORY.pop if last && (last.empty? || last == prev)
|
Readline::HISTORY.pop if last && (last.empty? || last == prev)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue