diff --git a/cpp/ycm/IdentifierCompleter.cpp b/cpp/ycm/IdentifierCompleter.cpp index 1bc9ca97..a0b44908 100644 --- a/cpp/ycm/IdentifierCompleter.cpp +++ b/cpp/ycm/IdentifierCompleter.cpp @@ -174,7 +174,7 @@ void IdentifierCompleter::ResultsForQueryAndType( std::vector< Result > &results ) const { FiletypeMap::const_iterator it = filetype_map_.find( filetype ); - if ( it == filetype_map_.end() ) + if ( it == filetype_map_.end() || query.empty() ) return; Bitset query_bitset = LetterBitsetFromString( query ); diff --git a/cpp/ycm/tests/IdentifierCompleter_test.cpp b/cpp/ycm/tests/IdentifierCompleter_test.cpp index efdfad89..37371ee6 100644 --- a/cpp/ycm/tests/IdentifierCompleter_test.cpp +++ b/cpp/ycm/tests/IdentifierCompleter_test.cpp @@ -64,6 +64,16 @@ std::vector< std::string > Candidates( const std::string &a, } // unnamed namespace +// This differs from what we expect from the ClangCompleter. That one should +// return results for an empty query. +TEST( IdentifierCompleterTest, EmptyQueryNoResults ) +{ + EXPECT_THAT( IdentifierCompleter( Candidates( + "foobar" ) ).CandidatesForQuery( "" ), + ElementsAre() ); +} + + TEST( IdentifierCompleterTest, OneCandidate ) { EXPECT_THAT( IdentifierCompleter( Candidates(