Don't complete url and title from same search word.

Resolves #4411:

> When opening a webpage, the suggested results will include those whose
> URL ends with the beginning of the string you've typed and whose title
> begins with the rest of the string.

By joining the url and title with a space, we ensure that the last word
of the url and the first word of the title are treated as separate
words.
This commit is contained in:
Ryan Roden-Corrent 2018-11-06 08:05:17 -05:00
parent 64f0e2471a
commit 2e562a926b
No known key found for this signature in database
GPG Key ID: 4E5072F68872BC04
2 changed files with 9 additions and 1 deletions

View File

@ -76,7 +76,7 @@ class HistoryCategory(QSqlQueryModel):
# given the search term "a b", the WHERE clause would be:
# ((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

View File

@ -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."""