[macruby-changes] [4887] DietRB/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 5 13:59:38 PDT 2010


Revision: 4887
          http://trac.macosforge.org/projects/ruby/changeset/4887
Author:   eloy.de.enige at gmail.com
Date:     2010-11-05 13:59:36 -0700 (Fri, 05 Nov 2010)
Log Message:
-----------
Don't try to complete an empty string at all.

Modified Paths:
--------------
    DietRB/trunk/lib/irb/ext/completion.rb
    DietRB/trunk/spec/ext/completion_spec.rb

Modified: DietRB/trunk/lib/irb/ext/completion.rb
===================================================================
--- DietRB/trunk/lib/irb/ext/completion.rb	2010-11-05 10:47:48 UTC (rev 4886)
+++ DietRB/trunk/lib/irb/ext/completion.rb	2010-11-05 20:59:36 UTC (rev 4887)
@@ -82,6 +82,8 @@
     end
     
     def results
+      return if @source.strip.empty?
+
       source = @source
       filter = nil
       

Modified: DietRB/trunk/spec/ext/completion_spec.rb
===================================================================
--- DietRB/trunk/spec/ext/completion_spec.rb	2010-11-05 10:47:48 UTC (rev 4886)
+++ DietRB/trunk/spec/ext/completion_spec.rb	2010-11-05 20:59:36 UTC (rev 4887)
@@ -46,6 +46,26 @@
   it "quacks like a Proc" do
     @completion.call('//.').should == imethods(Regexp, '//')
   end
+
+  it "completes reserved words as variables or constants" do
+    (IRB::Completion::RESERVED_DOWNCASE_WORDS +
+      IRB::Completion::RESERVED_UPCASE_WORDS).each do |word|
+      complete(word[0..-2]).should include(word)
+    end
+  end
+
+  it "completes file paths" do
+    complete("'/").should == Dir.glob('/*').sort.map { |f| "'#{f}" }
+    complete("'#{ROOT}/lib/../Ra").should == ["'#{File.join(ROOT, "Rakefile")}"]
+    complete("%{#{ROOT}/li").should == ['LICENSE', 'lib'].map { |f| "%{#{File.join(ROOT, f)}" }
+    complete("\"#{ROOT}/lib/").should == ['irb', 'irb.rb'].map { |f| "\"#{File.join(ROOT, 'lib', f)}" }
+  end
+
+  it "does not crash when trying to complete garbage" do
+    complete("").should == nil
+    complete("/").should == nil
+    complete("./Rake").should == nil
+  end
   
   describe "when doing a method call on an explicit receiver," do
     describe "and the source ends with a period," do
@@ -241,23 +261,4 @@
       complete("::CompletionSt").should == %w{ ::CompletionStub }
     end
   end
-  
-  it "completes reserved words as variables or constants" do
-    (IRB::Completion::RESERVED_DOWNCASE_WORDS +
-      IRB::Completion::RESERVED_UPCASE_WORDS).each do |word|
-      complete(word[0..-2]).should include(word)
-    end
-  end
-
-  it "completes file paths" do
-    complete("'/").should == Dir.glob('/*').sort.map { |f| "'#{f}" }
-    complete("'#{ROOT}/lib/../Ra").should == ["'#{File.join(ROOT, "Rakefile")}"]
-    complete("%{#{ROOT}/li").should == ['LICENSE', 'lib'].map { |f| "%{#{File.join(ROOT, f)}" }
-    complete("\"#{ROOT}/lib/").should == ['irb', 'irb.rb'].map { |f| "\"#{File.join(ROOT, 'lib', f)}" }
-  end
-
-  it "does not crash when trying to complete garbage" do
-    complete("/").should == nil
-    complete("./Rake").should == nil
-  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101105/fc6cec83/attachment.html>


More information about the macruby-changes mailing list