Skip to content

Commit 58681ed

Browse files
committed
Fix ri Hash::\[\]
1 parent ae5ca03 commit 58681ed

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/rdoc/ri/driver.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,9 +996,9 @@ def name_regexp name
996996

997997
case type
998998
when '#', '::' then
999-
/^#{klass}#{type}#{name}$/
999+
/^#{klass}#{type}#{Regexp.escape name}$/
10001000
else
1001-
/^#{klass}(#|::)#{name}$/
1001+
/^#{klass}(#|::)#{Regexp.escape name}$/
10021002
end
10031003
end
10041004

test/test_rdoc_ri_driver.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,18 @@ def test_method_type
572572
def test_name_regexp
573573
assert_equal %r%^RDoc::AnyMethod#new$%,
574574
@driver.name_regexp('RDoc::AnyMethod#new')
575+
575576
assert_equal %r%^RDoc::AnyMethod::new$%,
576577
@driver.name_regexp('RDoc::AnyMethod::new')
577578

578579
assert_equal %r%^RDoc::AnyMethod(#|::)new$%,
579580
@driver.name_regexp('RDoc::AnyMethod.new')
581+
582+
assert_equal %r%^Hash(#|::)\[\]$%,
583+
@driver.name_regexp('Hash.[]')
584+
585+
assert_equal %r%^Hash::\[\]$%,
586+
@driver.name_regexp('Hash::[]')
580587
end
581588

582589
def test_list_known_classes

0 commit comments

Comments
 (0)