Respect web-history-max-items with SQL.
Use a LIMIT with the sql competion model to limit history entries as the old completion implementation did.
This commit is contained in:
parent
df995c02a3
commit
3f6f03e325
@ -20,6 +20,7 @@
|
|||||||
"""Function to return the url completion model for the `open` command."""
|
"""Function to return the url completion model for the `open` command."""
|
||||||
|
|
||||||
from qutebrowser.completion.models import sqlmodel
|
from qutebrowser.completion.models import sqlmodel
|
||||||
|
from qutebrowser.config import config
|
||||||
|
|
||||||
|
|
||||||
def url():
|
def url():
|
||||||
@ -32,7 +33,8 @@ def url():
|
|||||||
|
|
||||||
model = sqlmodel.SqlCompletionModel(column_widths=(40, 50, 10),
|
model = sqlmodel.SqlCompletionModel(column_widths=(40, 50, 10),
|
||||||
columns_to_filter=[urlcol, textcol])
|
columns_to_filter=[urlcol, textcol])
|
||||||
model.new_category('History')
|
model.new_category('History',
|
||||||
|
limit=config.get('completion', 'web-history-max-items'))
|
||||||
model.new_category('Quickmarks')
|
model.new_category('Quickmarks')
|
||||||
model.new_category('Bookmarks')
|
model.new_category('Bookmarks')
|
||||||
return model
|
return model
|
||||||
|
@ -268,8 +268,8 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks,
|
|||||||
- the most recent entries are included
|
- the most recent entries are included
|
||||||
"""
|
"""
|
||||||
# TODO: time formatting and item limiting
|
# TODO: time formatting and item limiting
|
||||||
#config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
|
config_stub.data['completion'] = {'timestamp-format': '%Y-%m-%d',
|
||||||
# 'web-history-max-items': 2}
|
'web-history-max-items': 2}
|
||||||
model = urlmodel.url()
|
model = urlmodel.url()
|
||||||
qtmodeltester.data_display_may_return_none = True
|
qtmodeltester.data_display_may_return_none = True
|
||||||
qtmodeltester.check(model)
|
qtmodeltester.check(model)
|
||||||
@ -303,8 +303,6 @@ def test_url_completion(qtmodeltester, config_stub, web_history, quickmarks,
|
|||||||
datetime(2015, 9, 5).timestamp()),
|
datetime(2015, 9, 5).timestamp()),
|
||||||
('https://python.org', 'Welcome to Python.org',
|
('https://python.org', 'Welcome to Python.org',
|
||||||
datetime(2016, 3, 8).timestamp()),
|
datetime(2016, 3, 8).timestamp()),
|
||||||
('https://github.com', 'https://github.com',
|
|
||||||
datetime(2016, 5, 1).timestamp()),
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ def test_first_last_item(data, first, last):
|
|||||||
assert model.data(model.first_item()) == first
|
assert model.data(model.first_item()) == first
|
||||||
assert model.data(model.last_item()) == last
|
assert model.data(model.last_item()) == last
|
||||||
|
|
||||||
|
|
||||||
def test_limit():
|
def test_limit():
|
||||||
table = sql.SqlTable('test_limit', ['a'], primary_key='a')
|
table = sql.SqlTable('test_limit', ['a'], primary_key='a')
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
|
Loading…
Reference in New Issue
Block a user