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

Handle negativity in Pry::Code#take_lines [Fixes #886]

This commit is contained in:
Conrad Irwin 2013-03-24 21:22:43 -07:00
parent bd320550c5
commit d24e95f7fd
2 changed files with 7 additions and 1 deletions

View file

@ -197,7 +197,7 @@ class Pry
if start_line >= 0
@lines.index { |loc| loc.lineno >= start_line } || @lines.length
else
@lines.length + start_line
[@lines.length + start_line, 0].max
end
alter do

View file

@ -79,6 +79,12 @@ describe "hist" do
out.should =~ /x\n\d+:.*y\n\d+:.*z/
end
it "should start from beginning if tail number is longer than history" do
@hist.push 'Hyacinth'
out = @t.eval 'hist --tail'
out.should =~ /Hyacinth/
end
it 'should apply --tail after --grep' do
@hist.push "print 1"
@hist.push "print 2"