From a04c3322cc97056404775463eccbe6032de08919 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 15 Jul 2012 19:44:35 -0700 Subject: [PATCH] No results for empty query (IdentifierCompleter) --- cpp/ycm/IdentifierCompleter.cpp | 2 +- cpp/ycm/tests/IdentifierCompleter_test.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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(