From e5f2d27ed979bf9a9ac09bb79bd461bcf0441707 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 22 Oct 2017 08:22:45 +1100 Subject: [PATCH] Ensure that a window with the given win_id exists --- qutebrowser/browser/commands.py | 4 ++++ tests/end2end/features/tabs.feature | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 256894d49..fbe41d6a8 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -555,6 +555,10 @@ class CommandDispatcher: tabbed_browser = self._new_tabbed_browser( private=self._tabbed_browser.private) else: + if win_id not in objreg.window_registry: + raise cmdexc.CommandError( + "There's no window with id {}!".format(win_id)) + tabbed_browser = objreg.get('tabbed-browser', scope='window', window=win_id) diff --git a/tests/end2end/features/tabs.feature b/tests/end2end/features/tabs.feature index e0728f10d..be82d85bd 100644 --- a/tests/end2end/features/tabs.feature +++ b/tests/end2end/features/tabs.feature @@ -1058,6 +1058,11 @@ Feature: Tab management And I run :tab-give Then the error "Cannot detach from a window with only one tab" should be shown + Scenario: Give a tab to a window ID that does not exist + When I open data/hello.txt + And I run :tab-give 99 + Then the error "There's no window with id 99!" should be shown + # Other Scenario: Using :tab-next after closing last tab (#1448)