No results for empty query (IdentifierCompleter)

This commit is contained in:
Strahinja Val Markovic 2012-07-15 19:44:35 -07:00
parent 52d8a1236b
commit a04c3322cc
2 changed files with 11 additions and 1 deletions

View File

@ -174,7 +174,7 @@ void IdentifierCompleter::ResultsForQueryAndType(
std::vector< Result > &results ) const std::vector< Result > &results ) const
{ {
FiletypeMap::const_iterator it = filetype_map_.find( filetype ); FiletypeMap::const_iterator it = filetype_map_.find( filetype );
if ( it == filetype_map_.end() ) if ( it == filetype_map_.end() || query.empty() )
return; return;
Bitset query_bitset = LetterBitsetFromString( query ); Bitset query_bitset = LetterBitsetFromString( query );

View File

@ -64,6 +64,16 @@ std::vector< std::string > Candidates( const std::string &a,
} // unnamed namespace } // 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 ) TEST( IdentifierCompleterTest, OneCandidate )
{ {
EXPECT_THAT( IdentifierCompleter( Candidates( EXPECT_THAT( IdentifierCompleter( Candidates(