mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
hist --replay now uses eval_string <<, fixes #443
This ensures that the replayed lines end up in the pry input cache. This behaviour is now inline with the way play works.
This commit is contained in:
parent
3a4041cb24
commit
a18d90b9e8
2 changed files with 18 additions and 11 deletions
|
@ -235,8 +235,10 @@ class Pry
|
|||
|
||||
def process_replay
|
||||
@history = @history.between(opts[:r])
|
||||
_pry_.input_stack << _pry_.input
|
||||
_pry_.input = StringIO.new(@history.raw)
|
||||
|
||||
# not 100% sure why i need the \n here, but i do.
|
||||
eval_string << "#{@history.raw}\n"
|
||||
run "show-input" unless _pry_.complete_expression?(eval_string)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -276,24 +276,29 @@ describe "Pry::DefaultCommands::Input" do
|
|||
end
|
||||
|
||||
it 'should replay history correctly (single item)' do
|
||||
@hist.push ":blah"
|
||||
@hist.push ":bucket"
|
||||
@hist.push ":ostrich"
|
||||
o = Object.new
|
||||
@hist.push "@x = 10"
|
||||
@hist.push "@y = 20"
|
||||
@hist.push "@z = 30"
|
||||
str_output = StringIO.new
|
||||
redirect_pry_io(InputTester.new("hist --replay -1", "exit-all"), str_output) do
|
||||
pry
|
||||
o.pry
|
||||
end
|
||||
str_output.string.should =~ /ostrich/
|
||||
o.instance_variable_get(:@x).should == nil
|
||||
o.instance_variable_get(:@y).should == nil
|
||||
o.instance_variable_get(:@z).should == 30
|
||||
end
|
||||
|
||||
it 'should replay a range of history correctly (range of items)' do
|
||||
@hist.push ":hello"
|
||||
@hist.push ":carl"
|
||||
o = Object.new
|
||||
@hist.push "@x = 10"
|
||||
@hist.push "@y = 20"
|
||||
str_output = StringIO.new
|
||||
redirect_pry_io(InputTester.new("hist --replay 0..2", "exit-all"), str_output) do
|
||||
pry
|
||||
o.pry
|
||||
end
|
||||
str_output.string.should =~ /:hello\n.*:carl/
|
||||
o.instance_variable_get(:@x).should == 10
|
||||
o.instance_variable_get(:@y).should == 20
|
||||
end
|
||||
|
||||
it 'should grep for correct lines in history' do
|
||||
|
|
Loading…
Add table
Reference in a new issue