From c0ab474b21a7fc307d006eeb8f283fb43afc5007 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 16 Aug 2016 07:36:39 +1000 Subject: [PATCH] Give error when trying to detach a single tab --- qutebrowser/browser/commands.py | 2 ++ tests/end2end/features/tabs.feature | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 2964b6113..58b1f4d01 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -424,6 +424,8 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') def tab_detach(self): """Detach the current tab to its own window.""" + if self._count() < 2: + raise cmdexc.CommandError("Cannot detach one tab.") url = self._current_url() self._open(url, window=True) cur_widget = self._current_widget() diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index e7ad31fc8..6e8cb5e12 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -620,6 +620,12 @@ Feature: Tab management - history: - url: http://localhost:*/data/numbers/2.txt + Scenario: Detach tab from window with only one tab + Given I have a fresh instance + When I open data/hello.txt + And I run :tab-detach + Then the error "Cannot detach one tab." should be shown + # :undo Scenario: Undo without any closed tabs