*Really* fix completion with multiple words.

Turns out re.escape also escapes spaces, so we'd need to replace '(\\ )'
groups after escaping. At this point it's easier to just combine spaces
before escaping the pattern.

Fixes #1934.
Supersedes #1935.
This commit is contained in:
Florian Bruhin 2016-09-09 09:03:18 +02:00
parent 0a3853fcb7
commit 71a89bd418
2 changed files with 4 additions and 1 deletions

View File

@ -68,8 +68,9 @@ class CompletionFilterModel(QSortFilterProxyModel):
"""
with debug.log_time(log.completion, 'Setting filter pattern'):
self.pattern = val
val = re.sub(r' +', r' ', val) # See #1919
val = re.escape(val)
val = re.sub(r'\ +', r'.*', val)
val = val.replace(r'\ ', '.*')
self.pattern_re = re.compile(val, re.IGNORECASE)
self.invalidate()
sortcol = 0

View File

@ -64,6 +64,8 @@ def _extract_model_data(model):
('foo', 'barfoobar', True),
('foo bar', 'barfoobar', True),
('foo bar', 'barfoobar', True),
('foo bar', 'barfoobazbar', True),
('foo bar', 'barfoobazbar', True),
('foo', 'barFOObar', True),
('Foo', 'barfOObar', True),
('ab', 'aonebtwo', False),