From b5212f26628bac22ceed4ac66a6ff14f8c6e67e2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 6 Feb 2015 15:16:41 +0530 Subject: [PATCH] add leading word matches, fixes #2663 --- pandora/entity/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora/entity/views.py b/pandora/entity/views.py index 93ca52eea..eca623758 100644 --- a/pandora/entity/views.py +++ b/pandora/entity/views.py @@ -130,12 +130,15 @@ def autocompleteEntities(request, data): value_lower = data['value'].lower() matches = [] leading_matches = [] + leading_word_matches = [] for v in [e.name for e in qs]: if v.lower().startswith(value_lower): leading_matches.append(v) + elif [w for w in v.lower().split(' ') if w.strip().startswith(value_lower)]: + leading_word_matches.append(v) else: matches.append(v) - values = leading_matches + matches + values = leading_matches + leading_word_matches + matches else: values = [e.name for e in qs] values = values[data['range'][0]:data['range'][1]]