diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 76b267121..4195ed094 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -825,12 +825,18 @@ class CommandDispatcher: text = clipboard.text(mode) if not text: raise cmdexc.CommandError("{} is empty.".format(target)) - log.misc.debug("{} contained: '{}'".format(target, text)) - try: - url = urlutils.fuzzy_url(text) - except urlutils.InvalidUrlError as e: - raise cmdexc.CommandError(e) - self._open(url, tab, bg, window) + log.misc.debug("{} contained: '{}'".format(target, + text.replace('\n', '\\n'))) + text_urls = enumerate([u for u in text.split('\n') if u != '']) + for i, text_url in text_urls: + if not window and i > 0: + 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', count='count') diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 3d856f396..72de45fc6 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -199,6 +199,7 @@ def selection_supported(qapp): def fill_clipboard(qtbot, qapp, httpbin, what, content): mode = _clipboard_mode(qapp, what) content = content.replace('(port)', str(httpbin.port)) + content = content.replace('\\n', '\n') clipboard = qapp.clipboard() with qtbot.waitSignal(clipboard.changed): diff --git a/tests/integration/features/yankpaste.feature b/tests/integration/features/yankpaste.feature index e4a0dbfe6..89a2d8426 100644 --- a/tests/integration/features/yankpaste.feature +++ b/tests/integration/features/yankpaste.feature @@ -104,3 +104,62 @@ Feature: Yanking and pasting. And I put "foo bar" into the clipboard And I run :paste 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 +