mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Move history pushing before command execution
This separates out concerns a little better, and paves the way for extracing process_command from retreive_line.
This commit is contained in:
parent
e59cd57ebf
commit
bb96695c8a
4 changed files with 9 additions and 8 deletions
|
@ -29,7 +29,8 @@ class Pry
|
|||
end
|
||||
|
||||
def process
|
||||
@history = Pry::Code(Pry.history.to_a)
|
||||
# The last value in history will be the 'hist' command itself
|
||||
@history = Pry::Code(Pry.history.to_a[0..-2])
|
||||
|
||||
if opts.present?(:show)
|
||||
@history = @history.between(opts[:show])
|
||||
|
|
|
@ -422,12 +422,10 @@ class Pry
|
|||
# Pry's input.
|
||||
interactive = !input.is_a?(StringIO)
|
||||
|
||||
begin
|
||||
if !process_command(val, eval_string, target)
|
||||
eval_string << "#{indented_val.chomp}\n" unless val.empty?
|
||||
end
|
||||
ensure
|
||||
Pry.history << indented_val if interactive
|
||||
Pry.history << indented_val if interactive
|
||||
|
||||
if !process_command(val, eval_string, target)
|
||||
eval_string << "#{indented_val.chomp}\n" unless val.empty?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ class PryTester
|
|||
|
||||
def initialize(context = TOPLEVEL_BINDING, options = {})
|
||||
@pry = Pry.new(options)
|
||||
@history = options[:history]
|
||||
|
||||
if context
|
||||
target = Pry.binding_for(context)
|
||||
|
@ -122,6 +123,7 @@ class PryTester
|
|||
|
||||
strs.flatten.each do |str|
|
||||
str = "#{str.strip}\n"
|
||||
@history.push str if @history
|
||||
if @pry.process_command(str)
|
||||
result = last_command_result_or_output
|
||||
else
|
||||
|
|
|
@ -6,7 +6,7 @@ describe "hist" do
|
|||
@hist = Pry.history
|
||||
|
||||
@str_output = StringIO.new
|
||||
@t = pry_tester do
|
||||
@t = pry_tester :history => @hist do
|
||||
# For looking at what hist pushes into the input stack. The
|
||||
# implementation of this helper will definitely have to change at some
|
||||
# point.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue