filter: Clear the result set before filtering
Ocarina was preserving the results set even if there were 0 search results for the entire search string. So a search for "walllllll" would still return results for "wall". Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
be72339b2d
commit
8fd5d8173e
|
@ -114,6 +114,7 @@ void filter :: search(const std::string &text, std::set<unsigned int> &res)
|
|||
std::list<std::string>::iterator it;
|
||||
IndexEntry *found;
|
||||
|
||||
res.clear();
|
||||
parse_text(text, parsed);
|
||||
if (parsed.size() == 0)
|
||||
return;
|
||||
|
|
|
@ -64,7 +64,8 @@ static void test_add()
|
|||
static void do_test_search(const std::string &text, unsigned int len,
|
||||
unsigned int *ids)
|
||||
{
|
||||
std::set<unsigned int> res;
|
||||
int init_values[] = { 1, 2, 3, 4, 5 };
|
||||
std::set<unsigned int> res(init_values, init_values + 5);
|
||||
std::set<unsigned int>::iterator it;
|
||||
|
||||
filter :: search(text, res);
|
||||
|
@ -96,9 +97,7 @@ static void test_search()
|
|||
|
||||
unsigned int res5[] = {};
|
||||
do_test_search("unknown terms", 0, res5);
|
||||
|
||||
unsigned int res6[] = {};
|
||||
do_test_search("the chestZ", 0, res6);
|
||||
do_test_search("the chestZ", 0, res5);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Reference in New Issue