Merge branch 'edit-url' of https://github.com/blyxxyz/qutebrowser into blyxxyz-edit-url

This commit is contained in:
Florian Bruhin 2016-07-01 13:40:00 +02:00
commit af37272246
2 changed files with 20 additions and 19 deletions

View File

@ -1930,9 +1930,7 @@ class CommandDispatcher:
nam.clear_all_ssl_errors()
@cmdutils.register(instance='command-dispatcher', scope='window')
@cmdutils.argument('count', count=True)
def edit_url(self, url=None, bg=False, tab=False, window=False,
count=None):
def edit_url(self, url=None, bg=False, tab=False, window=False):
"""Navigate to a url formed in an external editor.
The editor which should be launched can be configured via the
@ -1943,17 +1941,19 @@ class CommandDispatcher:
bg: Open in a new background tab.
tab: Open in a new tab.
window: Open in a new window.
count: The tab index to open the URL in, or None.
"""
cmdutils.check_exclusive((tab, bg, window), 'tbw')
old_url = self._current_url().toString()
ed = editor.ExternalEditor(self._win_id, self._tabbed_browser)
# Passthrough for openurl args (e.g. -t, -b, -w)
ed.editing_finished.connect(functools.partial(
self.openurl, bg=bg, tab=tab, window=window, count=count))
self._open_if_changed, old_url=old_url, bg=bg, tab=tab,
window=window))
ed.edit(url or self._current_url().toString())
ed.edit(url or old_url)
@cmdutils.register(instance='command-dispatcher', scope='window')
def set_mark(self, key):
@ -1972,3 +1972,17 @@ class CommandDispatcher:
key: mark identifier; capital indicates a global mark
"""
self._tabbed_browser.jump_mark(key)
def _open_if_changed(self, url=None, old_url=None, bg=False, tab=False,
window=False):
"""Open a URL unless it's already open in the tab.
Args:
old_url: The original URL to compare against.
url: The URL to open.
bg: Open in a new background tab.
tab: Open in a new tab.
window: Open in a new window.
"""
if bg or tab or window or url != old_url:
self.openurl(url=url, bg=bg, tab=tab, window=window)

View File

@ -47,19 +47,6 @@ Feature: Opening external editors
- active: true
url: http://localhost:*/data/numbers/2.txt
Scenario: Editing an URL with count
Given I have a fresh instance
When I open data/numbers/1.txt
And I run :tab-only
And I open about:blank in a new tab
And I run :tab-focus 1
And I set up a fake editor replacing "1.txt" by "2.txt"
And I run :edit-url with count 2
Then data/numbers/2.txt should be loaded
And the following tabs should be open:
- data/numbers/1.txt (active)
- data/numbers/2.txt
Scenario: Editing an 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