[前][次][番号順一覧][スレッド一覧]

ruby-changes:26461

From: tarui <ko1@a...>
Date: Fri, 21 Dec 2012 01:02:54 +0900 (JST)
Subject: [ruby-changes:26461] tarui:r38512 (trunk): * lib/irb/completion.rb (CompletionProc): support completion of

tarui	2012-12-21 01:02:43 +0900 (Fri, 21 Dec 2012)

  New Revision: 38512

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38512

  Log:
    * lib/irb/completion.rb (CompletionProc): support completion of
      instance variables. [ruby-dev:46710] [Bug #7520]

  Modified files:
    trunk/ChangeLog
    trunk/lib/irb/completion.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38511)
+++ ChangeLog	(revision 38512)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Dec 21 01:01:45 2012  Masaya Tarui  <tarui@r...>
+
+	* lib/irb/completion.rb (CompletionProc): support completion of
+	  instance variables. [ruby-dev:46710] [Bug #7520]
+
 Thu Dec 20 20:58:25 2012  Masaya Tarui  <tarui@r...>
 
 	* vm_trace.c (rb_suppress_tracing): bugfix for vm->trace_running
Index: lib/irb/completion.rb
===================================================================
--- lib/irb/completion.rb	(revision 38511)
+++ lib/irb/completion.rb	(revision 38512)
@@ -152,9 +152,10 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/completion.rb#L152
 
 	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 https://github.com/ruby/ruby/blob/trunk/lib/irb/completion.rb#L202
 	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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]