From 4d9a98a11d5b8e953ed9540ad0e1897b15b6368b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 8 May 2016 21:18:30 +0200 Subject: [PATCH] Paste clipboard with :paste-primary on Windows --- qutebrowser/browser/commands.py | 2 +- tests/integration/features/conftest.py | 7 +++++++ tests/integration/features/yankpaste.feature | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 6d82d9939..b9e189825 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1400,7 +1400,7 @@ class CommandDispatcher: try: sel = utils.get_clipboard(selection=True) except utils.SelectionUnsupportedError: - return + sel = utils.get_clipboard() log.misc.debug("Pasting primary selection into element {}".format( elem.debug_text())) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 863cc1a25..1f3633a8b 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -202,6 +202,13 @@ def selection_supported(qapp): pytest.skip("OS doesn't support primary selection!") +@bdd.when("selection is not supported") +def selection_not_supported(qapp): + """Skip the test if selection is supported.""" + if qapp.clipboard().supportsSelection(): + pytest.skip("OS supports primary selection!") + + @bdd.when(bdd.parsers.re(r'I put "(?P.*)" into the ' r'(?Pprimary selection|clipboard)')) def fill_clipboard(quteproc, httpbin, what, content): diff --git a/tests/integration/features/yankpaste.feature b/tests/integration/features/yankpaste.feature index 58ae304b0..1fcb14fbc 100644 --- a/tests/integration/features/yankpaste.feature +++ b/tests/integration/features/yankpaste.feature @@ -276,3 +276,14 @@ Feature: Yanking and pasting. And I run :enter-mode insert And I run :paste-primary Then the error "Focused element is not editable!" should be shown + + Scenario: :paste-primary without primary selection supported + When selection is not supported + And I open data/paste_primary.html + And I put "Hello world" into the clipboard + # Click the text field + And I run :hint all + And I run :follow-hint a + And I run :paste-primary + # Compare + Then the text field should contain "Hello world"