mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Completion for show-source/show-doc/?/$ Array#<tab>
This commit is contained in:
parent
5246700e2b
commit
7547b8ca16
2 changed files with 22 additions and 0 deletions
|
@ -234,6 +234,12 @@ class Pry
|
|||
run action, *args
|
||||
end
|
||||
|
||||
c.class_eval do
|
||||
define_method(:complete) do |input|
|
||||
cmd.new(context).complete(input)
|
||||
end
|
||||
end
|
||||
|
||||
c.group "Aliases"
|
||||
|
||||
c
|
||||
|
|
|
@ -127,6 +127,22 @@ class Pry
|
|||
retry
|
||||
end
|
||||
end
|
||||
|
||||
def complete(input)
|
||||
if input =~ /([^ ]*)#([a-z0-9_]*)\z/
|
||||
prefix, search = [$1, $2]
|
||||
methods = begin
|
||||
Pry::Method.all_from_class(binding.eval(prefix))
|
||||
rescue RescuableException => e
|
||||
return super
|
||||
end
|
||||
methods.map do |method|
|
||||
[prefix, method.name].join('#') if method.name.start_with?(search)
|
||||
end.compact
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue