From 9d3e675296a5f0aaf0ccd2766a58a68b621e3452 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 15 Jan 2021 10:11:53 +0100 Subject: Fix :tab-only without tabs e.g. when running 'qutebrowser --temp-basedir :tab-only' --- doc/changelog.asciidoc | 2 ++ qutebrowser/browser/commands.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 8190540f8..cf2faf9e6 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -170,6 +170,8 @@ Fixed contains a proper extension. Before this fix, qutebrowser would use the URL's data contents as filename with QtWebEngine; or "binary blob" with the Qt network stack. +- When `:tab-only` is run before a tab is available, an error is now shown + instead of crashing. - TODO: Due to a long-standing bug in the `pkg_resources` dependency, it caused qutebrowser's startup to slow down by around 150ms-1s (heavily depending on the system). Since the dependency is now removed, qutebrowser's startup time diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index ec43a3210..936af5402 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -764,7 +764,8 @@ class CommandDispatcher: """ cmdutils.check_exclusive((prev, next_), 'pn') cur_idx = self._tabbed_browser.widget.currentIndex() - assert cur_idx != -1 + if cur_idx == -1: + raise cmdutils.CommandError("Failed to get current tab for :tab-only") def _to_close(i): """Helper method to check if a tab should be closed or not.""" -- cgit v1.2.3-54-g00ecf