From e613d01263a4d49fb19144094cbf49447b172012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=82czyk?= Date: Wed, 30 Nov 2016 13:35:08 +0100 Subject: [PATCH 1/4] Fixed problems with tab completion after moving tabs (#2141) --- qutebrowser/browser/commands.py | 6 +----- qutebrowser/completion/models/miscmodels.py | 1 + tests/end2end/features/completion.feature | 12 ++++++++++++ tests/helpers/stubs.py | 6 +++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 97fc8c186..c3038ee71 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1028,17 +1028,13 @@ class CommandDispatcher: raise cmdexc.CommandError("Can't move tab to position {}!".format( new_idx + 1)) - tab = self._current_widget() cur_idx = self._current_index() - icon = self._tabbed_browser.tabIcon(cur_idx) - label = self._tabbed_browser.page_title(cur_idx) cmdutils.check_overflow(cur_idx, 'int') cmdutils.check_overflow(new_idx, 'int') self._tabbed_browser.setUpdatesEnabled(False) try: color = self._tabbed_browser.tab_indicator_color(cur_idx) - self._tabbed_browser.removeTab(cur_idx) - self._tabbed_browser.insertTab(new_idx, tab, icon, label) + self._tabbed_browser.tabBar().moveTab(cur_idx, new_idx) self._set_current_index(new_idx) self._tabbed_browser.set_tab_indicator_color(new_idx, color) finally: diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py index 14a48c399..450549057 100644 --- a/qutebrowser/completion/models/miscmodels.py +++ b/qutebrowser/completion/models/miscmodels.py @@ -160,6 +160,7 @@ class TabCompletionModel(base.BaseCompletionModel): tab.title_changed.connect(self.rebuild) tab.shutting_down.connect(self.delayed_rebuild) tabbed_browser.new_tab.connect(self.on_new_tab) + tabbed_browser.tabBar().tabMoved.connect(self.rebuild) objreg.get("app").new_window.connect(self.on_new_window) self.rebuild() diff --git a/tests/end2end/features/completion.feature b/tests/end2end/features/completion.feature index 0cc23a215..87db94e8d 100644 --- a/tests/end2end/features/completion.feature +++ b/tests/end2end/features/completion.feature @@ -102,3 +102,15 @@ Feature: Using completion And I run :completion-item-del Then the following tabs should be open: - data/hello.txt (active) + + Scenario: Go to tab after moving a tab + Given I have a fresh instance + When I open data/hello.txt + And I open data/hello2.txt in a new tab + # Tricking completer into not updating tabs + And I run :set-cmd-text -s :buffer + And I run :tab-move 1 + And I run :buffer hello2.txt + Then the following tabs should be open: + - data/hello2.txt (active) + - data/hello.txt diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 50f4e545e..627d77d62 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -27,7 +27,7 @@ from unittest import mock from PyQt5.QtCore import pyqtSignal, QPoint, QProcess, QObject from PyQt5.QtNetwork import (QNetworkRequest, QAbstractNetworkCache, QNetworkCacheMetaData) -from PyQt5.QtWidgets import QCommonStyle, QLineEdit, QWidget +from PyQt5.QtWidgets import QCommonStyle, QLineEdit, QWidget, QTabBar from qutebrowser.browser import browsertab, history from qutebrowser.config import configexc @@ -571,6 +571,7 @@ class TabbedBrowserStub(QObject): super().__init__(parent) self.tabs = [] self.shutting_down = False + self._qtabbar = QTabBar() def count(self): return len(self.tabs) @@ -584,6 +585,9 @@ class TabbedBrowserStub(QObject): def on_tab_close_requested(self, idx): del self.tabs[idx] + def tabBar(self): + return QTabBar(self._qtabbar) + class ApplicationStub(QObject): From 2fca442892ceece2fd6630f49e4551a298c5d8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=82czyk?= Date: Wed, 30 Nov 2016 15:23:35 +0100 Subject: [PATCH 2/4] Fixed TabbedBrowserStub's tabBar, no longer toggling updates while moving tabs --- qutebrowser/browser/commands.py | 12 ++++-------- tests/helpers/stubs.py | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index c3038ee71..fa010f9e2 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1031,14 +1031,10 @@ class CommandDispatcher: cur_idx = self._current_index() cmdutils.check_overflow(cur_idx, 'int') cmdutils.check_overflow(new_idx, 'int') - self._tabbed_browser.setUpdatesEnabled(False) - try: - color = self._tabbed_browser.tab_indicator_color(cur_idx) - self._tabbed_browser.tabBar().moveTab(cur_idx, new_idx) - self._set_current_index(new_idx) - self._tabbed_browser.set_tab_indicator_color(new_idx, color) - finally: - self._tabbed_browser.setUpdatesEnabled(True) + color = self._tabbed_browser.tab_indicator_color(cur_idx) + self._tabbed_browser.tabBar().moveTab(cur_idx, new_idx) + self._set_current_index(new_idx) + self._tabbed_browser.set_tab_indicator_color(new_idx, color) @cmdutils.register(instance='command-dispatcher', scope='window', maxsplit=0, no_replace_variables=True) diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 627d77d62..dfbcc550d 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -586,7 +586,7 @@ class TabbedBrowserStub(QObject): del self.tabs[idx] def tabBar(self): - return QTabBar(self._qtabbar) + return self._qtabbar class ApplicationStub(QObject): From 63808fdb98d7a7549f6f8769f9826c5ceaf0b9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=82czyk?= Date: Thu, 1 Dec 2016 00:44:07 +0100 Subject: [PATCH 3/4] Removed handling of tab's position and color since it's done by QTabBar --- qutebrowser/browser/commands.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index fa010f9e2..0c86431b7 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1031,10 +1031,7 @@ class CommandDispatcher: cur_idx = self._current_index() cmdutils.check_overflow(cur_idx, 'int') cmdutils.check_overflow(new_idx, 'int') - color = self._tabbed_browser.tab_indicator_color(cur_idx) self._tabbed_browser.tabBar().moveTab(cur_idx, new_idx) - self._set_current_index(new_idx) - self._tabbed_browser.set_tab_indicator_color(new_idx, color) @cmdutils.register(instance='command-dispatcher', scope='window', maxsplit=0, no_replace_variables=True) From 568b2560560d3c536dc9ee7da599974546c7ba20 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 1 Dec 2016 13:25:15 +0100 Subject: [PATCH 4/4] Regenerate authors --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 0f28676ac..272828b37 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -172,6 +172,7 @@ Contributors, sorted by the number of commits in descending order: * Austin Anderson * Jimmy * Niklas Haas +* Maciej Wołczyk * Spreadyy * Alexey "Averrin" Nabrodov * nanjekyejoannah @@ -181,7 +182,6 @@ Contributors, sorted by the number of commits in descending order: * John ShaggyTwoDope Jenkins * Clayton Craft * Peter Vilim -* Maciej Wołczyk * knaggita * Oliver Caldwell * Julian Weigt