From 24f466b2c35441c40179dde89279225fa1fc0fb9 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 26 Oct 2017 22:13:35 -0400 Subject: [PATCH] Add --related flag to edit-url. --- qutebrowser/browser/commands.py | 14 +++++++++----- tests/end2end/features/editor.feature | 10 ++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 6c8394771..93956157b 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -2113,7 +2113,7 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', scope='window') def edit_url(self, url=None, bg=False, tab=False, window=False, - private=False): + private=False, related=False): """Navigate to a url formed in an external editor. The editor which should be launched can be configured via the @@ -2125,6 +2125,8 @@ class CommandDispatcher: tab: Open in a new tab. window: Open in a new window. private: Open a new window in private browsing mode. + related: If opening a new tab, position the tab as related to the + current one (like clicking on a link). """ cmdutils.check_exclusive((tab, bg, window), 'tbw') @@ -2135,7 +2137,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, private=private)) + window=window, private=private, related=related)) ed.edit(url or old_url) @@ -2160,7 +2162,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, private=False): + window=False, private=False, related=False): """Open a URL unless it's already open in the tab. Args: @@ -2170,10 +2172,12 @@ class CommandDispatcher: tab: Open in a new tab. window: Open in a new window. private: Open a new window in private browsing mode. + related: If opening a new tab, position the tab as related to the + current one (like clicking on a link). """ - if bg or tab or window or private or url != old_url: + if bg or tab or window or private or related or url != old_url: self.openurl(url=url, bg=bg, tab=tab, window=window, - private=private) + private=private, related=related) @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 dbbc06879..d3c634b0d 100644 --- a/tests/end2end/features/editor.feature +++ b/tests/end2end/features/editor.feature @@ -23,6 +23,16 @@ Feature: Opening external editors - data/numbers/1.txt - data/numbers/2.txt (active) + Scenario: Editing a URL with -rt + When I set tabs.new_position.related to prev + And I open data/numbers/1.txt + And I set up a fake editor replacing "1.txt" by "2.txt" + And I run :edit-url -rt + Then data/numbers/2.txt should be loaded + And the following tabs should be open: + - data/numbers/2.txt (active) + - data/numbers/1.txt + Scenario: Editing a URL with -b When I run :tab-only And I open data/numbers/1.txt