Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't try to complete an empty string at all.

git-svn-id: http://svn.macosforge.org/repository/ruby/DietRB/trunk@4887 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
commit 7ad3571f6ce18568e1afd38709dabdcdcd0d3178 1 parent 332378b
Eloy Durán alloy authored
Showing with 22 additions and 19 deletions.
  1. +2 −0  lib/irb/ext/completion.rb
  2. +20 −19 spec/ext/completion_spec.rb
2  lib/irb/ext/completion.rb
View
@@ -82,6 +82,8 @@ def constants
end
def results
+ return if @source.strip.empty?
+
source = @source
filter = nil
39 spec/ext/completion_spec.rb
View
@@ -46,6 +46,26 @@ def a_local_method; end
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 @@ def a_local_method; end
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
Please sign in to comment.
Something went wrong with that request. Please try again.