mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Currently searches for '..X' match only items exactly equal to '.X'. Change to make such a search match that and also any exactly-matching embedded hierarchical components, such as 'A.X' and 'A.X.Z'. This means that one cannot search for *only* '.X' if there is a hierarchical subitem with the name X, but I think this case will be exceedingly rare.
This commit is contained in:
parent
4b7575252e
commit
028d2fc04b
@ -123,14 +123,23 @@ REGEXP_MATCH = 2
|
||||
def _match(query, value, matchkind):
|
||||
if query.startswith('..'):
|
||||
query = query[1:]
|
||||
prefix_match_ok = False
|
||||
sq = query[1:]
|
||||
internal_match_ok = True
|
||||
else:
|
||||
prefix_match_ok = True
|
||||
internal_match_ok = False
|
||||
for t in value:
|
||||
t = icu_lower(t)
|
||||
try: ### ignore regexp exceptions, required because search-ahead tries before typing is finished
|
||||
if (matchkind == EQUALS_MATCH):
|
||||
if prefix_match_ok and query[0] == '.':
|
||||
if internal_match_ok:
|
||||
print query, t
|
||||
if query == t:
|
||||
return True
|
||||
comps = [c.strip() for c in t.split('.') if c.strip()]
|
||||
for comp in comps:
|
||||
if sq == comp:
|
||||
return True
|
||||
elif query[0] == '.':
|
||||
if t.startswith(query[1:]):
|
||||
ql = len(query) - 1
|
||||
if (len(t) == ql) or (t[ql:ql+1] == '.'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user