Escape leading periods with a second periond on non-hierarchical item searches.

This commit is contained in:
Charles Haley 2011-03-02 20:05:36 +00:00
parent 6ef6e9d6b9
commit 509e014996
2 changed files with 11 additions and 3 deletions

View File

@ -1591,9 +1591,11 @@ class TagsModel(QAbstractItemModel): # {{{
if tag in nodes_seen: if tag in nodes_seen:
continue continue
nodes_seen.add(tag) nodes_seen.add(tag)
n = name.replace(r'"', r'\"')
if name.startswith('.'):
n = '.' + n
ans.append('%s%s:"=%s%s"'%(prefix, category, ans.append('%s%s:"=%s%s"'%(prefix, category,
'.' if use_prefix else '', '.' if use_prefix else '', n))
name.replace(r'"', r'\"')))
return ans return ans
def find_item_node(self, key, txt, start_path, equals_match=False): def find_item_node(self, key, txt, start_path, equals_match=False):

View File

@ -121,11 +121,17 @@ CONTAINS_MATCH = 0
EQUALS_MATCH = 1 EQUALS_MATCH = 1
REGEXP_MATCH = 2 REGEXP_MATCH = 2
def _match(query, value, matchkind): def _match(query, value, matchkind):
if query.startswith('..'):
print 'here', query
query = query[1:]
prefix_match_ok = False
else:
prefix_match_ok = True
for t in value: for t in value:
t = icu_lower(t) t = icu_lower(t)
try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished
if (matchkind == EQUALS_MATCH): if (matchkind == EQUALS_MATCH):
if query[0] == '.': if prefix_match_ok and query[0] == '.':
if t.startswith(query[1:]): if t.startswith(query[1:]):
ql = len(query) - 1 ql = len(query) - 1
if (len(t) == ql) or (t[ql:ql+1] == '.'): if (len(t) == ql) or (t[ql:ql+1] == '.'):