File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -291,6 +291,15 @@ def constant_completion_candidates(name, nesting)
291
291
292
292
# Top level constants
293
293
entries . concat ( @entries_tree . search ( name ) )
294
+
295
+ # Filter only constants since methods may have names that look like constants
296
+ entries . each do |definitions |
297
+ definitions . select! do |entry |
298
+ entry . is_a? ( Entry ::Constant ) || entry . is_a? ( Entry ::ConstantAlias ) ||
299
+ entry . is_a? ( Entry ::Namespace ) || entry . is_a? ( Entry ::UnresolvedConstantAlias )
300
+ end
301
+ end
302
+
294
303
entries . uniq!
295
304
entries #: as Array[Array[Entry::Constant | Entry::ConstantAlias | Entry::Namespace | Entry::UnresolvedConstantAlias]]
296
305
end
Original file line number Diff line number Diff line change @@ -1983,6 +1983,18 @@ class Baz
1983
1983
assert_equal ( [ "XQRK" ] , result . map { |entries | entries . first &.name } )
1984
1984
end
1985
1985
1986
+ def test_constant_completion_does_not_confuse_uppercase_methods
1987
+ index ( <<~RUBY )
1988
+ class Foo
1989
+ def Qux
1990
+ end
1991
+ end
1992
+ RUBY
1993
+
1994
+ candidates = @index . constant_completion_candidates ( "Q" , [ ] )
1995
+ refute_includes ( candidates . flat_map { |entries | entries . map ( &:name ) } , "Qux" )
1996
+ end
1997
+
1986
1998
def test_constant_completion_candidates_for_empty_name
1987
1999
index ( <<~RUBY )
1988
2000
module Foo
You can’t perform that action at this time.
0 commit comments