summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/irb/completion.rb5
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 87d1155c9e..856a23102c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Dec 21 01:01:45 2012 Masaya Tarui <tarui@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* vm_trace.c (rb_suppress_tracing): bugfix for vm->trace_running
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