Search ListCategory in any order of search terms
This commit is contained in:
parent
3b04cb1d99
commit
6671dbf2b4
|
|
@ -61,9 +61,7 @@ class ListCategory(QSortFilterProxyModel):
|
|||
log.completion.warning(f"Trimming {len(val)}-char pattern to 5000")
|
||||
val = val[:5000]
|
||||
self._pattern = val
|
||||
val = re.sub(r' +', r' ', val) # See #1919
|
||||
val = re.escape(val)
|
||||
val = val.replace(r'\ ', '.*')
|
||||
val = '(?=.*' + ')(?=.*'.join(map(re.escape, val.split())) + ')'
|
||||
rx = QRegularExpression(val, QRegularExpression.PatternOption.CaseInsensitiveOption)
|
||||
qtutils.ensure_valid(rx)
|
||||
self.setFilterRegularExpression(rx)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ from qutebrowser.completion.models import listcategory
|
|||
[('foo', 'bar'), ('bar', 'foo'), ('bar', 'bar')],
|
||||
[('foo', 'bar'), ('bar', 'foo')],
|
||||
[('foo', 'bar'), ('bar', 'foo')]),
|
||||
|
||||
('foo bar',
|
||||
[('foobar', ''), ('barfoo', ''), ('foobaz', '')],
|
||||
[('barfoo', ''), ('foobar', '')],
|
||||
[('foobar', ''), ('barfoo', '')]),
|
||||
])
|
||||
def test_set_pattern(pattern, before, after, after_nosort, model_validator):
|
||||
"""Validate the filtering and sorting results of set_pattern."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue