modulus approach for show-method working 100%

This commit is contained in:
John Mair 2011-05-24 23:02:29 +12:00
parent 07046765ee
commit 54f4f3e797
3 changed files with 10 additions and 5 deletions

View File

@ -62,7 +62,10 @@ class Pry
code = strip_comments_from_c_code(code)
when :ruby
if meth.source_location.first == "(pry)"
code = strip_leading_whitespace(Pry.expr_store[meth.source_location.last])
bucket = (meth.source_location.last / 1000) * 1000
line = meth.source_location.last % 1000
p = Pry.new(:input => StringIO.new(Pry.expr_store[bucket].each_line.to_a[line..-1].join)).r(target)
code = strip_leading_whitespace(p)
else
code = strip_leading_whitespace(meth.source)
end

View File

@ -253,8 +253,8 @@ class Pry
@should_load_rc = true
@rc_loaded = false
@cli = false
@current_expr = -1
@expr_store = []
@current_expr = 0
@expr_store = {}
end
# Basic initialization.

View File

@ -191,8 +191,10 @@ class Pry
# This also sets the `_` local for the session.
expr = r(target)
Pry.expr_store << expr
set_last_result(target.eval(expr, "(pry)", Pry.current_expr += 1), target)
Pry.expr_store[Pry.current_expr] = expr
result = set_last_result(target.eval(expr, "(pry)", Pry.current_expr), target)
Pry.current_expr += 1000
result
rescue SystemExit => e
exit
rescue Exception => e