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

Allow negative ranges in hist --show

Remove duplicate `opts[:show]` check in hist.
This commit is contained in:
Brian Graham 2019-07-31 22:37:22 -04:00
parent 846b7ecb6f
commit 113670040c
2 changed files with 9 additions and 2 deletions

View file

@ -52,8 +52,6 @@ class Pry
@history.take_lines(1, opts[:head] || 10)
elsif opts.present?(:tail)
@history.take_lines(-(opts[:tail] || 10), opts[:tail] || 10)
elsif opts.present?(:show)
@history.between(opts[:show])
else
@history
end

View file

@ -132,6 +132,15 @@ describe "hist" do
expect(out).to match(/b\n\d+:.*c\n\d+:.*d/)
end
it 'should show lines between offsets A and B with the --show switch' do
("a".."f").each do |v|
@hist.push v
end
out = @t.eval 'hist --show -4..-2'
expect(out).to eq "3: c\n4: d\n5: e\n"
end
it "should store a call with `--replay` flag" do
@t.eval ":banzai"
@t.eval "hist --replay 1"