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

show-method should now work for eval methods

This commit is contained in:
John Mair 2011-05-25 00:34:55 +12:00
parent 54f4f3e797
commit 5e11ff46a8
3 changed files with 12 additions and 10 deletions

View file

@ -62,9 +62,9 @@ class Pry
code = strip_comments_from_c_code(code)
when :ruby
if meth.source_location.first == "(pry)"
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)
start_line = meth.source_location.last
p = Pry.new(:input => StringIO.new(Pry.line_buffer[start_line..-1].join)).r(target)
code = strip_leading_whitespace(p)
else
code = strip_leading_whitespace(meth.source)

View file

@ -117,10 +117,10 @@ class Pry
attr_accessor :config
# @return [Fixnum] The current input line.
attr_accessor :current_expr
attr_accessor :current_line
# @return [Array] The Array of evaluated expressions.
attr_accessor :expr_store
attr_accessor :line_buffer
# plugin forwardables
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
@ -253,8 +253,8 @@ class Pry
@should_load_rc = true
@rc_loaded = false
@cli = false
@current_expr = 0
@expr_store = {}
@current_line = 0
@line_buffer = []
end
# Basic initialization.

View file

@ -191,15 +191,16 @@ class Pry
# This also sets the `_` local for the session.
expr = r(target)
Pry.expr_store[Pry.current_expr] = expr
result = set_last_result(target.eval(expr, "(pry)", Pry.current_expr), target)
Pry.current_expr += 1000
Pry.line_buffer.push(*expr.each_line)
result = set_last_result(target.eval(expr, "(pry)", Pry.current_line), target)
result
rescue SystemExit => e
exit
rescue Exception => e
@last_result_is_exception = true
set_last_exception(e, target)
ensure
Pry.current_line += expr.each_line.to_a.size
end
# Perform a read.
@ -220,6 +221,7 @@ class Pry
loop do
val = retrieve_line(eval_string, target)
process_line(val, eval_string, target)
break if valid_expression?(eval_string)
end