Skip to content

Commit

Permalink
Merge pull request qutebrowser#4412 from rcorre/url-title-completion
Browse files Browse the repository at this point in the history
Don't complete url and title from same search word.
  • Loading branch information
The-Compiler authored Nov 14, 2018
2 parents 8dfca6f + bf10f48 commit 0786af0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions qutebrowser/completion/models/histcategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ def set_pattern(self, pattern):

# build a where clause to match all of the words in any order
# given the search term "a b", the WHERE clause would be:
# ((url || title) LIKE '%a%') AND ((url || title) LIKE '%b%')
# ((url || ' ' || title) LIKE '%a%') AND
# ((url || ' ' || title) LIKE '%b%')
where_clause = ' AND '.join(
"(url || title) LIKE :{} escape '\\'".format(i)
"(url || ' ' || title) LIKE :{} escape '\\'".format(i)
for i in range(len(words)))

# replace ' in timestamp-format to avoid breaking the query
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/completion/test_histcategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ def hist(init_sql, config_stub):
("ample itle",
[('example.com', 'title'), ('example.com', 'nope')],
[('example.com', 'title')]),
# https://github.com/qutebrowser/qutebrowser/issues/4411
("mlfreq",
[('https://qutebrowser.org/FAQ.html', 'Frequently Asked Questions')],
[]),
("ml freq",
[('https://qutebrowser.org/FAQ.html', 'Frequently Asked Questions')],
[('https://qutebrowser.org/FAQ.html', 'Frequently Asked Questions')]),
])
def test_set_pattern(pattern, before, after, model_validator, hist):
"""Validate the filtering and sorting results of set_pattern."""
Expand Down

0 comments on commit 0786af0

Please sign in to comment.