From 0a3853fcb78824372b4c19136c1c74562153c4e3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 8 Sep 2016 21:59:18 +0200 Subject: [PATCH] Fix handling of spaces in completion This is a regression introduced in faa052ad6f2b04afcf5bc8bb3d1481c8f74a5d6d. Fixes #1934. --- qutebrowser/completion/models/sortfilter.py | 2 +- tests/unit/completion/test_sortfilter.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/qutebrowser/completion/models/sortfilter.py b/qutebrowser/completion/models/sortfilter.py index c5b0596b1..b1c836ce2 100644 --- a/qutebrowser/completion/models/sortfilter.py +++ b/qutebrowser/completion/models/sortfilter.py @@ -69,7 +69,7 @@ class CompletionFilterModel(QSortFilterProxyModel): with debug.log_time(log.completion, 'Setting filter pattern'): self.pattern = val val = re.escape(val) - val = val.replace(r'\ +', r'.*') + val = re.sub(r'\ +', r'.*', val) self.pattern_re = re.compile(val, re.IGNORECASE) self.invalidate() sortcol = 0 diff --git a/tests/unit/completion/test_sortfilter.py b/tests/unit/completion/test_sortfilter.py index e3ae69146..68642a71b 100644 --- a/tests/unit/completion/test_sortfilter.py +++ b/tests/unit/completion/test_sortfilter.py @@ -62,6 +62,8 @@ def _extract_model_data(model): @pytest.mark.parametrize('pattern, data, expected', [ ('foo', 'barfoobar', True), + ('foo bar', 'barfoobar', True), + ('foo bar', 'barfoobar', True), ('foo', 'barFOObar', True), ('Foo', 'barfOObar', True), ('ab', 'aonebtwo', False),