Skip to content

Commit 557ebe4

Browse files
committed
Fix completion of IO::o
1 parent 3b96857 commit 557ebe4

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

History.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
Ruby commit r30811 by Usaku Nakamura.
1111
* Remove unnecessary (and wrong) platform-dependent hacks. Ruby commit
1212
r30829 by Usaku Nakamura.
13-
* Completing via Array#[<tab> in `ri -i` no longer crashes.
13+
* Completing via Array#[ in `ri -i` no longer crashes. Ruby Bug #3167
14+
* Completing IO::o in `ri -i` now returns results. Ruby Bug #3167
1415

1516
=== 3.5.3 / 2010-02-06
1617

lib/rdoc/ri/driver.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ def complete name
526526
if name !~ /#|\./ then
527527
completions = klasses.grep(/^#{klass_name}[^:]*$/)
528528
completions.concat klasses.grep(/^#{name}[^:]*$/) if name =~ /::$/
529+
530+
completions << klass if classes.key? klass # to complete a method name
529531
elsif selector then
530532
completions << klass if classes.key? klass
531533
elsif classes.key? klass_name then
@@ -547,7 +549,7 @@ def complete name
547549
completions.push(*methods)
548550
end
549551

550-
completions.sort
552+
completions.sort.uniq
551553
end
552554

553555
##

test/test_rdoc_ri_driver.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'minitest/autorun'
44
require 'tmpdir'
55
require 'fileutils'
6+
require 'stringio'
67
require 'rdoc/ri/driver'
78

89
class TestRDocRIDriver < MiniTest::Unit::TestCase
@@ -252,9 +253,11 @@ def test_complete
252253
assert_equal %w[Foo ], @driver.complete('F')
253254
assert_equal %w[ Foo::Bar], @driver.complete('Foo::B')
254255

255-
assert_equal %w[Foo#Bar], @driver.complete('Foo#'), 'Foo#'
256-
assert_equal %w[Foo#Bar Foo::bar], @driver.complete('Foo.'), 'Foo.'
257-
assert_equal %w[Foo::Bar Foo::bar], @driver.complete('Foo::'), 'Foo::'
256+
assert_equal %w[Foo#Bar], @driver.complete('Foo#'), 'Foo#'
257+
assert_equal %w[Foo#Bar Foo::bar], @driver.complete('Foo.'), 'Foo.'
258+
assert_equal %w[Foo::Bar Foo::bar], @driver.complete('Foo::'), 'Foo::'
259+
260+
assert_equal %w[ Foo::bar], @driver.complete('Foo::b'), 'Foo::b'
258261
end
259262

260263
def test_complete_ancestor

0 commit comments

Comments
 (0)