diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py index 35beb24de..74b75aeb1 100644 --- a/qutebrowser/completion/models/miscmodels.py +++ b/qutebrowser/completion/models/miscmodels.py @@ -122,8 +122,8 @@ def _buffer(skip_win_id=None): tabs.append(("{}/{}".format(win_id, idx + 1), tab.url().toDisplayString(), tabbed_browser.widget.page_title(idx))) - cat = listcategory.ListCategory("{}".format(win_id), tabs, - delete_func=delete_buffer) + cat = listcategory.ListCategory( + str(win_id), tabs, delete_func=delete_buffer, sort=False) model.add_category(cat) return model diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index a8c7d9425..8d16b4142 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -20,6 +20,8 @@ """Tests for completion models.""" import collections +import random +import string from datetime import datetime import pytest @@ -593,6 +595,34 @@ def test_tab_completion_delete(qtmodeltester, fake_web_tab, app_stub, QUrl('https://duckduckgo.com')] +def test_tab_completion_not_sorted(qtmodeltester, fake_web_tab, app_stub, + win_registry, tabbed_browser_stubs): + """Ensure that the completion row order is the same as tab index order. + + Would be violated for more than 9 tabs if the completion was being + alphabetically sorted on the first column, or the others. + """ + expected = [] + for idx in range(1, 11): + url = "".join(random.sample(string.ascii_letters, 12)) + title = "".join(random.sample(string.ascii_letters, 12)) + expected.append(("0/{}".format(idx), url, title)) + + tabbed_browser_stubs[0].widget.tabs = [ + fake_web_tab(QUrl(tab[1]), tab[2], idx) + for idx, tab in enumerate(expected) + ] + model = miscmodels.buffer() + model.set_pattern('') + qtmodeltester.data_display_may_return_none = True + qtmodeltester.check(model) + + _check_completions(model, { + '0': expected, + '1': [], + }) + + def test_other_buffer_completion(qtmodeltester, fake_web_tab, app_stub, win_registry, tabbed_browser_stubs, info): tabbed_browser_stubs[0].widget.tabs = [