diff --git a/lib/pry/helpers/command_helpers.rb b/lib/pry/helpers/command_helpers.rb index 61730b91..dbd87688 100644 --- a/lib/pry/helpers/command_helpers.rb +++ b/lib/pry/helpers/command_helpers.rb @@ -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) diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index f94afa67..66059a36 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -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. diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 6f04f56b..53b6e138 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -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