From b6f1dd963d6bee73a6a15022e855a45e6282f839 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 10 Feb 2016 06:40:54 +0100 Subject: [PATCH] Handle Shift-Insert correctly in prompt mode. Fixes #1299. --- CHANGELOG.asciidoc | 1 + qutebrowser/misc/miscwidgets.py | 26 +++++++++++----------- tests/integration/features/prompts.feature | 14 ++++++++++++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 786604805..4a79c8543 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -36,6 +36,7 @@ Changed - `:navigate increment/decrement` now preserves leading zeroes in URLs. - `general -> editor` can now also handle `{}` inside another argument (e.g. to open `vim` via `termite`) - Improved performance when scrolling with many tabs open. +- Shift-Insert now also pastes primary selection for prompts. Fixed ~~~~~ diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py index 87ef99905..208cef5ec 100644 --- a/qutebrowser/misc/miscwidgets.py +++ b/qutebrowser/misc/miscwidgets.py @@ -42,6 +42,19 @@ class MinimalLineEditMixin: """) self.setAttribute(Qt.WA_MacShowFocusRect, False) + def keyPressEvent(self, e): + """Override keyPressEvent to paste primary selection on Shift + Ins.""" + if e.key() == Qt.Key_Insert and e.modifiers() == Qt.ShiftModifier: + try: + text = utils.get_clipboard(selection=True) + except utils.SelectionUnsupportedError: + pass + else: + e.accept() + self.insert(text) + return + super().keyPressEvent(e) + def __repr__(self): return utils.get_repr(self) @@ -98,19 +111,6 @@ class CommandLineEdit(QLineEdit): if mark: self.setSelection(self._promptlen, oldpos - self._promptlen) - def keyPressEvent(self, e): - """Override keyPressEvent to paste primary selection on Shift + Ins.""" - if e.key() == Qt.Key_Insert and e.modifiers() == Qt.ShiftModifier: - try: - text = utils.get_clipboard(selection=True) - except utils.SelectionUnsupportedError: - pass - else: - e.accept() - self.insert(text) - return - super().keyPressEvent(e) - class _CommandValidator(QValidator): diff --git a/tests/integration/features/prompts.feature b/tests/integration/features/prompts.feature index f00c1184d..94059f399 100644 --- a/tests/integration/features/prompts.feature +++ b/tests/integration/features/prompts.feature @@ -58,6 +58,20 @@ Feature: Prompts And I run :leave-mode Then the javascript message "Prompt reply: null" should be logged + + # Shift-Insert with prompt (issue 1299) + + @pyqt531_or_newer + Scenario: Pasting via shift-insert in prompt mode + When selection is supported + And I put "insert test" into the primary selection + And I open data/prompt/jsprompt.html + And I click the button + And I wait for a prompt + And I press the keys "" + And I run :prompt-accept + Then the javascript message "Prompt reply: insert test" should be logged + @pyqt531_or_newer Scenario: Using content -> ignore-javascript-prompt When I set content -> ignore-javascript-prompt to true