From a3ffae8322d724b9355de1225e852222509ad34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 26 Mar 2014 16:19:06 +0100 Subject: [PATCH] improve behaviour when there is a single search term (#4570) --- src/collective/dms/thesaurus/browser/thesaurusview.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/collective/dms/thesaurus/browser/thesaurusview.py b/src/collective/dms/thesaurus/browser/thesaurusview.py index 1ddd386..2c30b9b 100644 --- a/src/collective/dms/thesaurus/browser/thesaurusview.py +++ b/src/collective/dms/thesaurus/browser/thesaurusview.py @@ -134,9 +134,7 @@ class ListKeywordsView(BrowserView): other = [] q = query_string.lower() regex = re.compile(r"[\s'()]") - q_words = regex.split(q) items = self.getItems(query_string) - done = {} for normalized, title, id in items: count_start = 0 count_in = 0 @@ -148,7 +146,9 @@ class ListKeywordsView(BrowserView): count_in += 1 item = '%s|%s' % (title, id) - if count_start == len(query_terms): + if len(query_terms) == 1 and normalized.startswith(query_terms[0]): + absolute_startswith.append((normalized, item)) + elif len(query_terms) > 1 and count_start == len(query_terms): absolute_startswith.append((normalized, item)) elif count_start >= 1: startswith.append((normalized, item))