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

speed up hist --exclude-pry

This commit is contained in:
Ryan Fitzgerald 2012-01-15 13:42:09 -08:00
parent b11528dd68
commit 25ae1c4d15
2 changed files with 18 additions and 25 deletions

View file

@ -270,7 +270,7 @@ class Pry
end
if @with_line_numbers
max_width = @lines.last.last.to_s.length if @lines.length > 0
max_width = lines.last.last.to_s.length if lines.length > 0
lines.each do |l|
padded_line_num = l[1].to_s.rjust(max_width)
l[0] = "#{Pry::Helpers::Text.blue(padded_line_num)}: #{l[0]}"

View file

@ -164,12 +164,25 @@ class Pry
end
def process
@history = Pry::Code(Pry.history.to_a[0..-2])
@history = Pry::Code(Pry.history.to_a)
if opts.present?(:e)
@history = @history.select do |l, ln|
!command_set.valid_command?(l)
@history = case
when opts.present?(:head)
@history.between(1, opts[:head] || 10)
when opts.present?(:tail)
@history.between(-(opts[:tail] || 10), -1)
when opts.present?(:show)
@history.between(opts[:show])
else
@history
end
if opts.present?(:grep)
@history = @history.grep(opts[:grep])
end
if opts.present?(:'exclude-pry')
@history = @history.select { |l, ln| !command_set.valid_command?(l) }
end
if opts.present?(:save)
@ -184,29 +197,10 @@ class Pry
end
def process_display
if opts.present?(:'exclude-pry')
@history = @history.select { |l, ln| !command_set.valid_command?(l) }
end
if opts.present?(:grep)
@history = @history.grep(opts[:grep])
end
unless opts.present?(:'no-numbers')
@history = @history.with_line_numbers
end
@history = case
when opts.present?(:head)
@history.between(1, opts[:head] || 10)
when opts.present?(:tail)
@history.between(-(opts[:tail] || 10), -1)
when opts.present?(:show)
@history.between(opts[:show])
else
@history
end
render_output(@history, opts)
end
@ -244,7 +238,6 @@ class Pry
end
alias_command "history", "hist"
end
end
end