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:
parent
b11528dd68
commit
25ae1c4d15
2 changed files with 18 additions and 25 deletions
|
@ -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]}"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue