From 03cb9c353ba539c6558ac643b8b7f53606e78824 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 25 Aug 2014 15:28:07 +0200 Subject: [PATCH] Fix clipboard selection in :paste on windows. --- qutebrowser/browser/commands.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 08b58f708..e1225d892 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -562,11 +562,17 @@ class CommandDispatcher: sel: True to use primary selection, False to use clipboard tab: True to open in a new tab. """ - mode = QClipboard.Selection if sel else QClipboard.Clipboard - text = QApplication.clipboard().text(mode) + clipboard = QApplication.clipboard() + if sel and clipboard.supportsSelection(): + mode = QClipboard.Selection + target = "Primary selection" + else: + mode = QClipboard.Clipboard + target = "Clipboard" + text = clipboard.text(mode) if not text: - raise CommandError("Clipboard is empty.") - log.misc.debug("Clipboard contained: '{}'".format(text)) + raise CommandError("{} is empty.".format(target)) + log.misc.debug("{} contained: '{}'".format(target, text)) try: url = urlutils.fuzzy_url(text) except urlutils.FuzzyUrlError as e: