diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 8f5019499..6c8394771 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -2112,7 +2112,8 @@ class CommandDispatcher: self._current_widget().clear_ssl_errors() @cmdutils.register(instance='command-dispatcher', scope='window') - def edit_url(self, url=None, bg=False, tab=False, window=False): + def edit_url(self, url=None, bg=False, tab=False, window=False, + private=False): """Navigate to a url formed in an external editor. The editor which should be launched can be configured via the @@ -2123,6 +2124,7 @@ class CommandDispatcher: bg: Open in a new background tab. tab: Open in a new tab. window: Open in a new window. + private: Open a new window in private browsing mode. """ cmdutils.check_exclusive((tab, bg, window), 'tbw') @@ -2133,7 +2135,7 @@ class CommandDispatcher: # Passthrough for openurl args (e.g. -t, -b, -w) ed.editing_finished.connect(functools.partial( self._open_if_changed, old_url=old_url, bg=bg, tab=tab, - window=window)) + window=window, private=private)) ed.edit(url or old_url) @@ -2158,7 +2160,7 @@ class CommandDispatcher: self._tabbed_browser.jump_mark(key) def _open_if_changed(self, url=None, old_url=None, bg=False, tab=False, - window=False): + window=False, private=False): """Open a URL unless it's already open in the tab. Args: @@ -2167,9 +2169,11 @@ class CommandDispatcher: bg: Open in a new background tab. tab: Open in a new tab. window: Open in a new window. + private: Open a new window in private browsing mode. """ - if bg or tab or window or url != old_url: - self.openurl(url=url, bg=bg, tab=tab, window=window) + if bg or tab or window or private or url != old_url: + self.openurl(url=url, bg=bg, tab=tab, window=window, + private=private) @cmdutils.register(instance='command-dispatcher', scope='window') def fullscreen(self, leave=False): diff --git a/tests/end2end/features/editor.feature b/tests/end2end/features/editor.feature index 6c2f1144d..dbbc06879 100644 --- a/tests/end2end/features/editor.feature +++ b/tests/end2end/features/editor.feature @@ -2,6 +2,9 @@ Feature: Opening external editors + Background: + Given I have a fresh instance + ## :edit-url Scenario: Editing a URL @@ -49,6 +52,26 @@ Feature: Opening external editors - active: true url: http://localhost:*/data/numbers/2.txt + Scenario: Editing a URL with -p + When I open data/numbers/1.txt in a new tab + And I run :tab-only + And I set up a fake editor replacing "1.txt" by "2.txt" + And I run :edit-url -p + Then data/numbers/2.txt should be loaded + And the session should look like: + windows: + - tabs: + - active: true + history: + - active: true + url: http://localhost:*/data/numbers/1.txt + - tabs: + - active: true + history: + - active: true + url: http://localhost:*/data/numbers/2.txt + private: true + Scenario: Editing a URL with -t and -b When I run :edit-url -t -b Then the error "Only one of -t/-b/-w can be given!" should be shown