Fix pasting of empty URLs.

This commit is contained in:
Florian Bruhin 2016-02-02 06:37:49 +01:00
parent 2f9ec515db
commit 14042403f6
3 changed files with 20 additions and 2 deletions

View File

@ -826,11 +826,11 @@ class CommandDispatcher:
mode = QClipboard.Clipboard
target = "Clipboard"
text = clipboard.text(mode)
if not text:
if not text.strip():
raise cmdexc.CommandError("{} is empty.".format(target))
log.misc.debug("{} contained: '{}'".format(target,
text.replace('\n', '\\n')))
text_urls = enumerate(u for u in text.split('\n') if u)
text_urls = enumerate(u for u in text.split('\n') if u.strip())
for i, text_url in text_urls:
if not window and i > 0:
tab = False

View File

@ -210,6 +210,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(r'\n', '\n')
clipboard = qapp.clipboard()
with qtbot.waitSignal(clipboard.changed):

View File

@ -61,6 +61,11 @@ Feature: Yanking and pasting.
And I run :paste --sel
Then the error "Primary selection is empty." should be shown
Scenario: Pasting with a space in clipboard
When I put " " into the clipboard
And I run :paste
Then the error "Clipboard is empty." should be shown
Scenario: Pasting in a new tab
Given I open about:blank
When I run :tab-only
@ -171,6 +176,18 @@ Feature: Yanking and pasting.
- active: true
url: http://localhost:*/data/hello3.txt
Scenario: Pasting multiple urls with an empty one
When I open about:blank
And I put "http://localhost:(port)/data/hello.txt\n\nhttp://localhost:(port)/data/hello2.txt" into the clipboard
And I run :paste -t
Then no crash should happen
Scenario: Pasting multiple urls with an almost empty one
When I open about:blank
And I put "http://localhost:(port)/data/hello.txt\n \nhttp://localhost:(port)/data/hello2.txt" into the clipboard
And I run :paste -t
Then no crash should happen
#### :paste-primary
Scenario: Pasting the primary selection into an empty text field