diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 5a477b2da..561f5d6d6 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -51,6 +51,8 @@ Fixed - Fixed crash when downloading from an URL with SSL errors - Close file handles correctly when a download failed +- Fixed crash when using `;Y` (`:hint links yank-primary`) on a system without + primary selection v0.6.2 ------ diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 263cc9475..9590fa131 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -28,6 +28,7 @@ import string from PyQt5.QtCore import (pyqtSignal, pyqtSlot, QObject, QEvent, Qt, QUrl, QTimer) from PyQt5.QtGui import QMouseEvent +from PyQt5.QtWidgets import QApplication from PyQt5.QtWebKit import QWebElement from PyQt5.QtWebKitWidgets import QWebPage @@ -490,7 +491,12 @@ class HintManager(QObject): url: The URL to open as a QUrl. context: The HintContext to use. """ - sel = context.target == Target.yank_primary + if (context.target == Target.yank_primary and + QApplication.clipboard().supportsSelection()): + sel = True + else: + sel = False + urlstr = url.toString(QUrl.FullyEncoded | QUrl.RemovePassword) utils.set_clipboard(urlstr, selection=sel) diff --git a/tests/integration/features/conftest.py b/tests/integration/features/conftest.py index 1f3633a8b..48340bd98 100644 --- a/tests/integration/features/conftest.py +++ b/tests/integration/features/conftest.py @@ -418,8 +418,8 @@ def clipboard_contains(quteproc, httpbin, what, content): @bdd.then(bdd.parsers.parse('the clipboard should contain:\n{content}')) -def clipboard_contains_multiline(quteproc, content): - expected = textwrap.dedent(content) +def clipboard_contains_multiline(quteproc, httpbin, content): + expected = textwrap.dedent(content).replace('(port)', httpbin.port) quteproc.wait_for(message='Setting fake clipboard: {}'.format( json.dumps(expected))) diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index e4628e438..c2c057b60 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -57,3 +57,11 @@ Feature: Using hints And I run :hint all spawn -v echo And I run :follow-hint a Then the message "Command exited successfully" should be shown + + Scenario: Yanking to primary selection without it being supported (#1336) + When selection is not supported + And I run :debug-set-fake-clipboard + And I open data/hints/link.html + And I run :hint links yank-primary + And I run :follow-hint a + Then the clipboard should contain "http://localhost:(port)/data/hello.txt"