summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2019-12-30 22:23:17 +0100
committerFlorian Bruhin <me@the-compiler.org>2019-12-30 22:23:17 +0100
commitc0648553f1f3087154a4913b5948f440e9b86a1e (patch)
tree7618b1ad6f28d96f99597a528efb656c960102a0
parent575b61a0a250ce95d8ee946f79178c6060d5c3de (diff)
parentacb633318ef723f04f488be722b575190836045f (diff)
downloadqutebrowser-c0648553f1f3087154a4913b5948f440e9b86a1e.tar.gz
qutebrowser-c0648553f1f3087154a4913b5948f440e9b86a1e.zip
Merge remote-tracking branch 'origin/pr/5150'
-rw-r--r--qutebrowser/browser/commands.py6
-rw-r--r--qutebrowser/completion/models/miscmodels.py22
-rw-r--r--tests/end2end/features/tabs.feature8
-rw-r--r--tests/unit/completion/test_models.py28
4 files changed, 58 insertions, 6 deletions
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index 6c838edbf..ab7e60aed 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -434,6 +434,10 @@ class CommandDispatcher:
in which case the closest match will be taken.
keep: If given, keep the old tab around.
"""
+ if config.val.tabs.tabs_are_windows:
+ raise cmdutils.CommandError("Can't take tabs when using "
+ "windows as tabs")
+
tabbed_browser, tab = self._resolve_buffer_index(index)
if tabbed_browser is self._tabbed_browser:
@@ -1233,7 +1237,7 @@ class CommandDispatcher:
def toggle_inspector(self):
"""Toggle the web inspector.
- Note: Due a bug in Qt, the inspector will show incorrect request
+ Note: Due to a bug in Qt, the inspector will show incorrect request
headers in the network tab.
"""
tab = self._current_widget()
diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py
index a6d2b3b32..8c6f3ce11 100644
--- a/qutebrowser/completion/models/miscmodels.py
+++ b/qutebrowser/completion/models/miscmodels.py
@@ -21,7 +21,7 @@
import typing
-from qutebrowser.config import configdata
+from qutebrowser.config import config, configdata
from qutebrowser.utils import objreg, log
from qutebrowser.completion.models import completionmodel, listcategory, util
@@ -112,6 +112,10 @@ def _buffer(skip_win_id=None):
model = completionmodel.CompletionModel(column_widths=(6, 40, 54))
+ tabs_are_windows = config.val.tabs.tabs_are_windows
+ # list storing all single-tabbed windows when tabs_are_windows
+ windows = [] # type: typing.List[typing.Tuple[str, str, str]]
+
for win_id in objreg.window_registry:
if skip_win_id is not None and win_id == skip_win_id:
continue
@@ -119,15 +123,23 @@ def _buffer(skip_win_id=None):
window=win_id)
if tabbed_browser.shutting_down:
continue
- tabs = []
+ tabs = [] # type: typing.List[typing.Tuple[str, str, str]]
for idx in range(tabbed_browser.widget.count()):
tab = tabbed_browser.widget.widget(idx)
tabs.append(("{}/{}".format(win_id, idx + 1),
tab.url().toDisplayString(),
tabbed_browser.widget.page_title(idx)))
- cat = listcategory.ListCategory(
- str(win_id), tabs, delete_func=delete_buffer, sort=False)
- model.add_category(cat)
+ if tabs_are_windows:
+ windows += tabs
+ else:
+ cat = listcategory.ListCategory(
+ str(win_id), tabs, delete_func=delete_buffer, sort=False)
+ model.add_category(cat)
+
+ if tabs_are_windows:
+ win = listcategory.ListCategory(
+ "Windows", windows, delete_func=delete_buffer, sort=False)
+ model.add_category(win)
return model
diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature
index 485ab771a..747e6c19a 100644
--- a/tests/end2end/features/tabs.feature
+++ b/tests/end2end/features/tabs.feature
@@ -1204,6 +1204,14 @@ Feature: Tab management
And I run :tab-take 0/1
Then the error "Can't take a tab from the same window" should be shown
+ Scenario: Take a tab while using tabs_are_windows
+ Given I have a fresh instance
+ When I open data/numbers/1.txt
+ And I open data/numbers/2.txt in a new window
+ And I set tabs.tabs_are_windows to true
+ And I run :tab-take 0/1
+ Then the error "Can't take tabs when using windows as tabs" should be shown
+
# :tab-give
@xfail_norun # Needs qutewm
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index cdba937b2..00875a9a0 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -758,6 +758,34 @@ def test_tab_completion_not_sorted(qtmodeltester, fake_web_tab, win_registry,
})
+def test_tab_completion_tabs_are_windows(qtmodeltester, fake_web_tab,
+ win_registry, tabbed_browser_stubs,
+ config_stub):
+ """Verify tabs across all windows are listed under a single category."""
+ tabbed_browser_stubs[0].widget.tabs = [
+ fake_web_tab(QUrl('https://github.com'), 'GitHub', 0),
+ fake_web_tab(QUrl('https://wikipedia.org'), 'Wikipedia', 1),
+ fake_web_tab(QUrl('https://duckduckgo.com'), 'DuckDuckGo', 2),
+ ]
+ tabbed_browser_stubs[1].widget.tabs = [
+ fake_web_tab(QUrl('https://wiki.archlinux.org'), 'ArchWiki', 0),
+ ]
+
+ config_stub.val.tabs.tabs_are_windows = True
+ model = miscmodels.buffer()
+ model.set_pattern('')
+ qtmodeltester.check(model)
+
+ _check_completions(model, {
+ 'Windows': [
+ ('0/1', 'https://github.com', 'GitHub'),
+ ('0/2', 'https://wikipedia.org', 'Wikipedia'),
+ ('0/3', 'https://duckduckgo.com', 'DuckDuckGo'),
+ ('1/1', 'https://wiki.archlinux.org', 'ArchWiki'),
+ ]
+ })
+
+
def test_other_buffer_completion(qtmodeltester, fake_web_tab, win_registry,
tabbed_browser_stubs, info):
tabbed_browser_stubs[0].widget.tabs = [