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:
parent
bd320550c5
commit
d24e95f7fd
2 changed files with 7 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue