From 349b20cc9132c0b22a210dce8d6ff36699f0a3ce Mon Sep 17 00:00:00 2001 From: tarui Date: Thu, 20 Dec 2012 16:02:43 +0000 Subject: * lib/irb/completion.rb (CompletionProc): support completion of instance variables. [ruby-dev:46710] [Bug #7520] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/irb/completion.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/irb/completion.rb') diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index 7fd69a0a09..3f886f507c 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -152,9 +152,10 @@ module IRB gv = eval("global_variables", bind).collect{|m| m.to_s} lv = eval("local_variables", bind).collect{|m| m.to_s} + iv = eval("instance_variables", bind).collect{|m| m.to_s} cv = eval("self.class.constants", bind).collect{|m| m.to_s} - if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver + if (gv | lv | iv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver # foo.func and foo is var. OR # foo::func and foo is var. OR # foo::Const and foo is var. OR @@ -201,7 +202,7 @@ module IRB select_message(receiver, message, candidates) else - candidates = eval("methods | private_methods | local_variables | self.class.constants", bind).collect{|m| m.to_s} + candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s} (candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/) end -- cgit v1.2.3