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:
parent
54f4f3e797
commit
5e11ff46a8
3 changed files with 12 additions and 10 deletions
|
@ -62,9 +62,9 @@ class Pry
|
||||||
code = strip_comments_from_c_code(code)
|
code = strip_comments_from_c_code(code)
|
||||||
when :ruby
|
when :ruby
|
||||||
if meth.source_location.first == "(pry)"
|
if meth.source_location.first == "(pry)"
|
||||||
bucket = (meth.source_location.last / 1000) * 1000
|
|
||||||
line = meth.source_location.last % 1000
|
start_line = meth.source_location.last
|
||||||
p = Pry.new(:input => StringIO.new(Pry.expr_store[bucket].each_line.to_a[line..-1].join)).r(target)
|
p = Pry.new(:input => StringIO.new(Pry.line_buffer[start_line..-1].join)).r(target)
|
||||||
code = strip_leading_whitespace(p)
|
code = strip_leading_whitespace(p)
|
||||||
else
|
else
|
||||||
code = strip_leading_whitespace(meth.source)
|
code = strip_leading_whitespace(meth.source)
|
||||||
|
|
|
@ -117,10 +117,10 @@ class Pry
|
||||||
attr_accessor :config
|
attr_accessor :config
|
||||||
|
|
||||||
# @return [Fixnum] The current input line.
|
# @return [Fixnum] The current input line.
|
||||||
attr_accessor :current_expr
|
attr_accessor :current_line
|
||||||
|
|
||||||
# @return [Array] The Array of evaluated expressions.
|
# @return [Array] The Array of evaluated expressions.
|
||||||
attr_accessor :expr_store
|
attr_accessor :line_buffer
|
||||||
|
|
||||||
# plugin forwardables
|
# plugin forwardables
|
||||||
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
|
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
|
||||||
|
@ -253,8 +253,8 @@ class Pry
|
||||||
@should_load_rc = true
|
@should_load_rc = true
|
||||||
@rc_loaded = false
|
@rc_loaded = false
|
||||||
@cli = false
|
@cli = false
|
||||||
@current_expr = 0
|
@current_line = 0
|
||||||
@expr_store = {}
|
@line_buffer = []
|
||||||
end
|
end
|
||||||
|
|
||||||
# Basic initialization.
|
# Basic initialization.
|
||||||
|
|
|
@ -191,15 +191,16 @@ class Pry
|
||||||
# This also sets the `_` local for the session.
|
# This also sets the `_` local for the session.
|
||||||
expr = r(target)
|
expr = r(target)
|
||||||
|
|
||||||
Pry.expr_store[Pry.current_expr] = expr
|
Pry.line_buffer.push(*expr.each_line)
|
||||||
result = set_last_result(target.eval(expr, "(pry)", Pry.current_expr), target)
|
result = set_last_result(target.eval(expr, "(pry)", Pry.current_line), target)
|
||||||
Pry.current_expr += 1000
|
|
||||||
result
|
result
|
||||||
rescue SystemExit => e
|
rescue SystemExit => e
|
||||||
exit
|
exit
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
@last_result_is_exception = true
|
@last_result_is_exception = true
|
||||||
set_last_exception(e, target)
|
set_last_exception(e, target)
|
||||||
|
ensure
|
||||||
|
Pry.current_line += expr.each_line.to_a.size
|
||||||
end
|
end
|
||||||
|
|
||||||
# Perform a read.
|
# Perform a read.
|
||||||
|
@ -220,6 +221,7 @@ class Pry
|
||||||
loop do
|
loop do
|
||||||
val = retrieve_line(eval_string, target)
|
val = retrieve_line(eval_string, target)
|
||||||
process_line(val, eval_string, target)
|
process_line(val, eval_string, target)
|
||||||
|
|
||||||
break if valid_expression?(eval_string)
|
break if valid_expression?(eval_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue