summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2014-03-26 15:19:06 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2014-03-26 15:19:06 (GMT)
commita3ffae8322d724b9355de1225e852222509ad34f (patch)
tree5c36fe5f589cc22aeaee1b7e48dc16fbd441c11f
parentd20b6b4e5cd2ed8fbaa5466eb9f8014b400af388 (diff)
downloadcollective.dms.thesaurus-a3ffae8322d724b9355de1225e852222509ad34f.zip
collective.dms.thesaurus-a3ffae8322d724b9355de1225e852222509ad34f.tar.gz
collective.dms.thesaurus-a3ffae8322d724b9355de1225e852222509ad34f.tar.bz2
improve behaviour when there is a single search term (#4570)
-rw-r--r--src/collective/dms/thesaurus/browser/thesaurusview.py6
1 files 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))