Allows to paste multiple URLs
- The paste command will now open one tab/window per url if multiple URLs (separated by newline) are present in the clipboard - Adds the tests for the new multitab functionality - Changes test/integration/conftest.py to be able to insert newlines in the clipboard for the test
This commit is contained in:
parent
6327d0fe36
commit
1b31a3fee4
@ -825,12 +825,18 @@ class CommandDispatcher:
|
|||||||
text = clipboard.text(mode)
|
text = clipboard.text(mode)
|
||||||
if not text:
|
if not text:
|
||||||
raise cmdexc.CommandError("{} is empty.".format(target))
|
raise cmdexc.CommandError("{} is empty.".format(target))
|
||||||
log.misc.debug("{} contained: '{}'".format(target, text))
|
log.misc.debug("{} contained: '{}'".format(target,
|
||||||
try:
|
text.replace('\n', '\\n')))
|
||||||
url = urlutils.fuzzy_url(text)
|
text_urls = enumerate([u for u in text.split('\n') if u != ''])
|
||||||
except urlutils.InvalidUrlError as e:
|
for i, text_url in text_urls:
|
||||||
raise cmdexc.CommandError(e)
|
if not window and i > 0:
|
||||||
self._open(url, tab, bg, window)
|
tab = False
|
||||||
|
bg = True
|
||||||
|
try:
|
||||||
|
url = urlutils.fuzzy_url(text_url)
|
||||||
|
except urlutils.InvalidUrlError as e:
|
||||||
|
raise cmdexc.CommandError(e)
|
||||||
|
self._open(url, tab, bg, window)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
count='count')
|
count='count')
|
||||||
|
@ -199,6 +199,7 @@ def selection_supported(qapp):
|
|||||||
def fill_clipboard(qtbot, qapp, httpbin, what, content):
|
def fill_clipboard(qtbot, qapp, httpbin, what, content):
|
||||||
mode = _clipboard_mode(qapp, what)
|
mode = _clipboard_mode(qapp, what)
|
||||||
content = content.replace('(port)', str(httpbin.port))
|
content = content.replace('(port)', str(httpbin.port))
|
||||||
|
content = content.replace('\\n', '\n')
|
||||||
|
|
||||||
clipboard = qapp.clipboard()
|
clipboard = qapp.clipboard()
|
||||||
with qtbot.waitSignal(clipboard.changed):
|
with qtbot.waitSignal(clipboard.changed):
|
||||||
|
@ -104,3 +104,62 @@ Feature: Yanking and pasting.
|
|||||||
And I put "foo bar" into the clipboard
|
And I put "foo bar" into the clipboard
|
||||||
And I run :paste
|
And I run :paste
|
||||||
Then the error "Invalid URL" should be shown
|
Then the error "Invalid URL" should be shown
|
||||||
|
|
||||||
|
Scenario: Pasting multiple urls in a new tab
|
||||||
|
Given I have a fresh instance
|
||||||
|
When I run :tab-only
|
||||||
|
And I put "http://localhost:(port)/data/hello.txt\nhttp://localhost:(port)/data/hello2.txt\nhttp://localhost:(port)/data/hello3.txt" into the clipboard
|
||||||
|
And I run :paste -t
|
||||||
|
And I wait until data/hello.txt is loaded
|
||||||
|
And I wait until data/hello2.txt is loaded
|
||||||
|
And I wait until data/hello3.txt is loaded
|
||||||
|
Then the following tabs should be open:
|
||||||
|
- about:blank
|
||||||
|
- data/hello.txt (active)
|
||||||
|
- data/hello2.txt
|
||||||
|
- data/hello3.txt
|
||||||
|
|
||||||
|
Scenario: Pasting multiple urls in a background tab
|
||||||
|
Given I open about:blank
|
||||||
|
When I run :tab-only
|
||||||
|
And I put "http://localhost:(port)/data/hello.txt\nhttp://localhost:(port)/data/hello2.txt\nhttp://localhost:(port)/data/hello3.txt" into the clipboard
|
||||||
|
And I run :paste -b
|
||||||
|
And I wait until data/hello.txt is loaded
|
||||||
|
And I wait until data/hello2.txt is loaded
|
||||||
|
And I wait until data/hello3.txt is loaded
|
||||||
|
Then the following tabs should be open:
|
||||||
|
- about:blank (active)
|
||||||
|
- data/hello.txt
|
||||||
|
- data/hello2.txt
|
||||||
|
- data/hello3.txt
|
||||||
|
|
||||||
|
Scenario: Pasting multiple urls in new windows
|
||||||
|
Given I have a fresh instance
|
||||||
|
When I put "http://localhost:(port)/data/hello.txt\nhttp://localhost:(port)/data/hello2.txt\nhttp://localhost:(port)/data/hello3.txt" into the clipboard
|
||||||
|
And I run :paste -w
|
||||||
|
And I wait until data/hello.txt is loaded
|
||||||
|
And I wait until data/hello2.txt is loaded
|
||||||
|
And I wait until data/hello3.txt is loaded
|
||||||
|
Then the session should look like:
|
||||||
|
windows:
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: about:blank
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: http://localhost:*/data/hello.txt
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: http://localhost:*/data/hello2.txt
|
||||||
|
- tabs:
|
||||||
|
- active: true
|
||||||
|
history:
|
||||||
|
- active: true
|
||||||
|
url: http://localhost:*/data/hello3.txt
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user