diff options
author | toofar <toofar@spalge.com> | 2024-02-05 13:06:49 +1300 |
---|---|---|
committer | toofar <toofar@spalge.com> | 2024-02-08 22:51:52 +1300 |
commit | e04d991666e7427a5203761787655efd85ee71a7 (patch) | |
tree | 2bf053b054a11153820700b7e9d1443c8a83c047 | |
parent | 7beae17a8797992177e187c00765d695edc4a9d2 (diff) | |
download | qutebrowser-e04d991666e7427a5203761787655efd85ee71a7.tar.gz qutebrowser-e04d991666e7427a5203761787655efd85ee71a7.zip |
Fix active tab in session with collapsed tabs
We are now iteration over all tabs, including hidden ones that aren't in the
tab widget. So we can't use the index of the current tab within the tab widget
as a key into that list. Check the actual tab value instead.
I made `TabbedBrowser._current_tab()` public because it's useful, so why not! I
could have used `tabbed_browser.widget.currentWidget()` like some other places
do but if we where doing proper type checking in session.py we would also have
to do the None check that is already being done in TabbedBrowser. Also
accessing `some_other_object.widget` feels a little dirty, like it should be
private?
-rw-r--r-- | qutebrowser/mainwindow/tabbedbrowser.py | 10 | ||||
-rw-r--r-- | qutebrowser/misc/sessions.py | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index c07b9e1ad..741123ed9 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -377,7 +377,7 @@ class TabbedBrowser(QWidget): tab.history_item_triggered.connect( history.web_history.add_from_tab) - def _current_tab(self) -> browsertab.AbstractTab: + def current_tab(self) -> browsertab.AbstractTab: """Get the current browser tab. Note: The assert ensures the current tab is never None. @@ -586,7 +586,7 @@ class TabbedBrowser(QWidget): if newtab or self.widget.currentWidget() is None: self.tabopen(url, background=False) else: - self._current_tab().load_url(url) + self.current_tab().load_url(url) @pyqtSlot(int) def on_tab_close_requested(self, idx): @@ -672,7 +672,7 @@ class TabbedBrowser(QWidget): # Make sure the background tab has the correct initial size. # With a foreground tab, it's going to be resized correctly by the # layout anyways. - current_widget = self._current_tab() + current_widget = self.current_tab() tab.resize(current_widget.size()) self.widget.tab_index_changed.emit(self.widget.currentIndex(), self.widget.count()) @@ -1087,7 +1087,7 @@ class TabbedBrowser(QWidget): if key != "'": message.error("Failed to set mark: url invalid") return - point = self._current_tab().scroller.pos_px() + point = self.current_tab().scroller.pos_px() if key.isupper(): self._global_marks[key] = point, url @@ -1108,7 +1108,7 @@ class TabbedBrowser(QWidget): except qtutils.QtValueError: urlkey = None - tab = self._current_tab() + tab = self.current_tab() if key.isupper(): if key in self._global_marks: diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index 3bf2b99c9..9f7254958 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -330,8 +330,8 @@ class SessionManager(QObject): ] else: tabs = tabbed_browser.widgets() - for i, tab in enumerate(tabs): - active = i == tabbed_browser.widget.currentIndex() + for tab in tabs: + active = tab == tabbed_browser.current_tab() tab_data = self._save_tab(tab, active, with_history=with_history) |